Skip to contentSkip to conversation

ocfs2: add fixed metadata file support -v1

PATCH New Tiger Yang 1 participant 1 message Jan 12, 2011 OCFS2

lore
Share & tools
lore

Tiger Yang

author
#0 lore raw

PATCH 1/1 ocfs2: add fixed metadata file support -v1

The fixed metadata file created by ocfs2-tools and it can only be read/write by O_DIRECT. We can't change the metadata of the it, so we can't link, unlink, rename it, and we can't set attr and xattr on it. The benefit is we don't need cluster lock when we read/write it.

---
 fs/ocfs2/acl.c      |    3 ++
 fs/ocfs2/aops.c     |    4 ++-
 fs/ocfs2/file.c     |   81 +++++++++++++++++++++++++++++++++++++--------------
 fs/ocfs2/mmap.c     |    9 ++++--
 fs/ocfs2/namei.c    |    9 ++++++
 fs/ocfs2/ocfs2_fs.h |    1 +
 fs/ocfs2/xattr.c    |    9 ++++++
 7 files changed, 90 insertions(+), 26 deletions(-)
fs/ocfs2/acl.c +3 -0
index 704f6b1..c277777 100644
@@ -492,6 +492,9 @@ static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name,
 	struct posix_acl *acl;
 	int ret = 0;
 
+	if (OCFS2_I(dentry->d_inode)->ip_attr & OCFS2_FIXEDMETA_FL)
+		return -EPERM;
+
 	if (strcmp(name, "") != 0)
 		return -EINVAL;
 	if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
fs/ocfs2/aops.c +3 -1
index 0d7c554..7e3371c 100644
@@ -581,7 +581,9 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
 	ocfs2_iocb_clear_rw_locked(iocb);
 
 	level = ocfs2_iocb_rw_locked_level(iocb);
-	ocfs2_rw_unlock(inode, level);
+
+	if (!(OCFS2_I(inode)->ip_attr & OCFS2_FIXEDMETA_FL))
+		ocfs2_rw_unlock(inode, level);
 
 	if (is_async)
 		aio_complete(iocb, ret, 0);
fs/ocfs2/file.c +59 -22

165 lines not on this page · raw message

fs/ocfs2/mmap.c +6 -3
index 7e32db9..76be93c 100644
@@ -182,14 +182,17 @@ static const struct vm_operations_struct ocfs2_file_vm_ops = {
 int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	int ret = 0, lock_level = 0;
+	struct inode *inode = file->f_dentry->d_inode;
 
-	ret = ocfs2_inode_lock_atime(file->f_dentry->d_inode,
-				    file->f_vfsmnt, &lock_level);
+	if (OCFS2_I(inode)->ip_attr & OCFS2_FIXEDMETA_FL)
+		return -EPERM;
+
+	ret = ocfs2_inode_lock_atime(inode, file->f_vfsmnt, &lock_level);
 	if (ret < 0) {
 		mlog_errno(ret);
 		goto out;
 	}
-	ocfs2_inode_unlock(file->f_dentry->d_inode, lock_level);
+	ocfs2_inode_unlock(inode, lock_level);
 out:
 	vma->vm_ops = &ocfs2_file_vm_ops;
 	vma->vm_flags |= VM_CAN_NONLINEAR;
fs/ocfs2/namei.c +9 -0
index d14cad6..0b79bd2 100644
@@ -658,6 +658,9 @@ static int ocfs2_link(struct dentry *old_dentry,
 		   old_dentry->d_name.len, old_dentry->d_name.name,
 		   dentry->d_name.len, dentry->d_name.name);
 
+	if (OCFS2_I(inode)->ip_attr & OCFS2_FIXEDMETA_FL)
+		return -EPERM;
+
 	if (S_ISDIR(inode->i_mode))
 		return -EPERM;
 
@@ -815,6 +818,9 @@ static int ocfs2_unlink(struct inode *dir,
 	mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry,
 		   dentry->d_name.len, dentry->d_name.name);
 
+	if (OCFS2_I(inode)->ip_attr & OCFS2_FIXEDMETA_FL)
+		return -EPERM;
+
 	dquot_initialize(dir);
 
 	BUG_ON(dentry->d_parent->d_inode != dir);
@@ -1072,6 +1078,9 @@ static int ocfs2_rename(struct inode *old_dir,
 		   old_dentry->d_name.len, old_dentry->d_name.name,
 		   new_dentry->d_name.len, new_dentry->d_name.name);
 
+	if (OCFS2_I(old_inode)->ip_attr & OCFS2_FIXEDMETA_FL)
+		return -EPERM;
+
 	dquot_initialize(old_dir);
 	dquot_initialize(new_dir);
 
fs/ocfs2/ocfs2_fs.h +1 -0
index bf2e776..50ccc34 100644
@@ -264,6 +264,7 @@
 #define OCFS2_NOTAIL_FL			FS_NOTAIL_FL	/* file tail should not be merged */
 #define OCFS2_DIRSYNC_FL		FS_DIRSYNC_FL	/* dirsync behaviour (directories only) */
 #define OCFS2_TOPDIR_FL			FS_TOPDIR_FL	/* Top of directory hierarchies*/
+#define OCFS2_FIXEDMETA_FL		(0x00200000)	/* do not update metadata */
 #define OCFS2_RESERVED_FL		FS_RESERVED_FL	/* reserved for ext2 lib */
 
 #define OCFS2_FL_VISIBLE		FS_FL_USER_VISIBLE	/* User visible flags */
fs/ocfs2/xattr.c +9 -0
index 67cd439..8e38ab7 100644
@@ -7255,6 +7255,9 @@ static int ocfs2_xattr_security_set(struct dentry *dentry, const char *name,
 	if (strcmp(name, "") == 0)
 		return -EINVAL;
 
+	if (OCFS2_I(dentry->d_inode)->ip_attr & OCFS2_FIXEDMETA_FL)
+		return -EPERM;
+
 	return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_SECURITY,
 			       name, value, size, flags);
 }
@@ -7323,6 +7326,9 @@ static int ocfs2_xattr_trusted_set(struct dentry *dentry, const char *name,
 	if (strcmp(name, "") == 0)
 		return -EINVAL;
 
+	if (OCFS2_I(dentry->d_inode)->ip_attr & OCFS2_FIXEDMETA_FL)
+		return -EPERM;
+
 	return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_TRUSTED,
 			       name, value, size, flags);
 }
@@ -7379,6 +7385,9 @@ static int ocfs2_xattr_user_set(struct dentry *dentry, const char *name,
 	if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
 		return -EOPNOTSUPP;
 
+	if (OCFS2_I(dentry->d_inode)->ip_attr & OCFS2_FIXEDMETA_FL)
+		return -EPERM;
+
 	return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_USER,
 			       name, value, size, flags);
 }
Signature · 1 line
1.7.2.1