[Ocfs2-commits] mfasheh commits r925 - in trunk/src: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon May 17 20:07:44 CDT 2004
Author: mfasheh
Date: 2004-05-17 19:07:42 -0500 (Mon, 17 May 2004)
New Revision: 925
Modified:
trunk/src/file.c
trunk/src/inc/proto.h
trunk/src/inode.c
trunk/src/oin.c
Log:
* Add the function ocfs_inode_revalidate(). This is called from the
inode_operations callback in stat.c on 2.4 kernels. The good thing
about this is that we know i_sem state going into it, so this seems
like an excellent chance to recheck inodes from what's on disk (like
we used to do in dentry_revalidate). In 2.6, we simply call this
from our getattr function (which takes it's place).
* Add a bit of extra checking in ocfs_inode_open()
Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c 2004-05-17 23:29:06 UTC (rev 924)
+++ trunk/src/file.c 2004-05-18 00:07:42 UTC (rev 925)
@@ -1301,6 +1301,13 @@
sb = dentry->d_inode->i_sb;
osb = ((ocfs_super *) sb->s_fs_info);
+ err = ocfs_inode_revalidate(dentry);
+ if (err < 0) {
+ if (err != -ENOENT)
+ LOG_ERROR_STATUS(err);
+ goto bail;
+ }
+
stat->dev = inode->i_sb->s_dev;
stat->ino = inode->i_ino;
stat->mode = inode->i_mode;
@@ -1326,7 +1333,7 @@
#else
/*
* ocfs_getattr()
- *
+ * THIS FUNCTION IS UNUSED IN 2.4.x
*/
int ocfs_getattr (struct dentry *dentry, struct iattr *attr)
{
Modified: trunk/src/inc/proto.h
===================================================================
--- trunk/src/inc/proto.h 2004-05-17 23:29:06 UTC (rev 924)
+++ trunk/src/inc/proto.h 2004-05-18 00:07:42 UTC (rev 925)
@@ -283,4 +283,6 @@
void ocfs_get_vote_obj (ocfs_vote_obj *obj);
+int ocfs_inode_revalidate(struct dentry *dentry);
+
#endif /* _PROTO_H_ */
Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c 2004-05-17 23:29:06 UTC (rev 924)
+++ trunk/src/inode.c 2004-05-18 00:07:42 UTC (rev 925)
@@ -117,16 +117,25 @@
.rename = ocfs_rename,
.setattr = ocfs_setattr,
.getattr = ocfs_getattr,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+ .revalidate = ocfs_inode_revalidate,
+#endif
};
static struct inode_operations ocfs_file_iops = {
.setattr = ocfs_setattr,
.getattr = ocfs_getattr,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+ .revalidate = ocfs_inode_revalidate,
+#endif
};
struct inode_operations ocfs_symlink_inode_operations = {
readlink: page_readlink,
- follow_link: ocfs_follow_link
+ follow_link: ocfs_follow_link,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+ .revalidate = ocfs_inode_revalidate,
+#endif
};
/*
@@ -1632,3 +1641,68 @@
}
#endif
+
+/*
+ * ocfs_inode_revalidate()
+ *
+ * In 2.4, this is called only from stat.c always without i_sem before
+ * any stat operations go through. In 2.6, this is called from our own
+ * getattr.
+ */
+int ocfs_inode_revalidate(struct dentry *dentry)
+{
+ struct inode *inode = dentry->d_inode;
+ int status = 0;
+ int needs_trunc;
+ ocfs_super *osb;
+
+ LOG_ENTRY_ARGS("(inode = 0x%p, ino = %lu)\n", inode,
+ inode ? inode->i_ino : 0);
+
+ if (!inode) {
+ LOG_TRACE_STR("eep, no inode!\n");
+ status = -ENOENT;
+ goto no_inode;
+ }
+
+ osb = OCFS_SB(inode->i_sb);
+
+ down (&inode->i_sem);
+ down (&(OCFS_I(inode)->priv_sem));
+
+ if (INODE_DELETED(inode)) {
+ LOG_TRACE_STR("inode deleted!\n");
+ status = -ENOENT;
+ goto bail;
+ }
+
+ if (osb->publ_map == (1 << osb->node_num)) {
+ LOG_TRACE_STR ("Only node alive.");
+ goto bail;
+ }
+
+ /* if I hold cache lock, no revalidate needed */
+ if (ocfs_is_local_cache_lock(osb, inode)) {
+ LOG_TRACE_STR("local cache lock\n");
+ goto bail;
+ }
+
+ OCFS_I(inode)->needs_verification = 1;
+ status = ocfs_verify_update_inode(osb, inode, &needs_trunc, 0);
+ if (status < 0) {
+ LOG_ERROR_STATUS (status);
+ status = -ENOENT;
+ }
+
+bail:
+ up (&(OCFS_I(inode)->priv_sem));
+ up (&inode->i_sem);
+
+ if (needs_trunc)
+ ocfs_truncate_inode_pages(inode, 0);
+
+no_inode:
+
+ LOG_EXIT_STATUS(status);
+ return(status);
+}
Modified: trunk/src/oin.c
===================================================================
--- trunk/src/oin.c 2004-05-17 23:29:06 UTC (rev 924)
+++ trunk/src/oin.c 2004-05-18 00:07:42 UTC (rev 925)
@@ -253,6 +253,12 @@
local_handle = 0;
fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(fe_bh); /* read */
+ if (!IS_VALID_FILE_ENTRY(fe)) {
+ OCFS_BH_PUT_DATA(fe_bh);
+ status = -EINVAL;
+ LOG_ERROR_STATUS(status);
+ goto leave;
+ }
/* why do we update these here? */
OCFS_I(inode)->alloc_size = fe->alloc_size;
More information about the Ocfs2-commits
mailing list