[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH] Copy i_flags to gfs2 inode flags on write



  Hi,

  attached is a patch to copy i_flags to GFS2 specific i_di_di_flags. The
patch is compile-tested only. Steven, does it look OK to you?

								Honza

-- 
Jan Kara <jack suse cz>
SuSE CR Labs
Propagate flags such as S_APPEND, S_IMMUTABLE, etc. from i_flags into
gfs2-specific i_di.di_flags. Hence, when someone sets these flags via a
different interface than ioctl, they are stored correctly.

Signed-off-by: Jan Kara <jack suse cz>

diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6-4-ocfs2_flags_update/fs/gfs2/ondisk.c linux-2.6.21-rc6-5-gfs2_flags_update/fs/gfs2/ondisk.c
--- linux-2.6.21-rc6-4-ocfs2_flags_update/fs/gfs2/ondisk.c	2007-04-23 20:02:02.000000000 +0200
+++ linux-2.6.21-rc6-5-gfs2_flags_update/fs/gfs2/ondisk.c	2007-04-23 20:26:21.000000000 +0200
@@ -16,6 +16,7 @@
 #include <linux/gfs2_ondisk.h>
 #include <linux/lm_interface.h>
 #include "incore.h"
+#include "ops_file.h"
 
 #define pv(struct, member, fmt) printk(KERN_INFO "  "#member" = "fmt"\n", \
 				       struct->member);
@@ -136,9 +137,9 @@ void gfs2_quota_in(struct gfs2_quota_hos
 	qu->qu_value = be64_to_cpu(str->qu_value);
 }
 
-void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
+void gfs2_dinode_out(struct gfs2_inode *ip, void *buf)
 {
-	const struct gfs2_dinode_host *di = &ip->i_di;
+	struct gfs2_dinode_host *di = &ip->i_di;
 	struct gfs2_dinode *str = buf;
 
 	str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
@@ -163,6 +164,7 @@ void gfs2_dinode_out(const struct gfs2_i
 	str->di_goal_data = cpu_to_be64(di->di_goal_data);
 	str->di_generation = cpu_to_be64(di->di_generation);
 
+	gfs2_get_inode_flags(ip);
 	str->di_flags = cpu_to_be32(di->di_flags);
 	str->di_height = cpu_to_be16(di->di_height);
 	str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) &&
diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6-4-ocfs2_flags_update/fs/gfs2/ops_file.c linux-2.6.21-rc6-5-gfs2_flags_update/fs/gfs2/ops_file.c
--- linux-2.6.21-rc6-4-ocfs2_flags_update/fs/gfs2/ops_file.c	2007-04-10 17:09:55.000000000 +0200
+++ linux-2.6.21-rc6-5-gfs2_flags_update/fs/gfs2/ops_file.c	2007-04-23 20:10:55.000000000 +0200
@@ -207,6 +207,7 @@ static int gfs2_get_flags(struct file *f
 	if (error)
 		return error;
 
+	gfs2_get_inode_flags(ip);
 	fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_di.di_flags);
 	if (put_user(fsflags, ptr))
 		error = -EFAULT;
@@ -234,6 +235,23 @@ void gfs2_set_inode_flags(struct inode *
 	inode->i_flags = flags;
 }
 
+/* Propagate flags from i_flags to GFS2_I(inode)->i_di.di_flags */
+void gfs2_get_inode_flags(struct gfs2_inode *ip)
+{
+	unsigned int flags = ip->i_inode.i_flags;
+
+	ip->i_di.di_flags &= ~(GFS2_DIF_SYNC|GFS2_DIF_APPENDONLY|
+			GFS2_DIF_IMMUTABLE|GFS2_DIF_NOATIME);
+	if (flags & S_SYNC)
+		ip->i_di.di_flags |= GFS2_DIF_SYNC;
+	if (flags & S_APPEND)
+		ip->i_di.di_flags |= GFS2_DIF_APPENDONLY;
+	if (flags & S_IMMUTABLE)
+		ip->i_di.di_flags |= GFS2_DIF_IMMUTABLE;
+	if (flags & S_NOATIME)
+		ip->i_di.di_flags |= GFS2_DIF_NOATIME;
+}
+
 /* Flags that can be set by user space */
 #define GFS2_FLAGS_USER_SET (GFS2_DIF_JDATA|			\
 			     GFS2_DIF_DIRECTIO|			\
diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6-4-ocfs2_flags_update/fs/gfs2/ops_file.h linux-2.6.21-rc6-5-gfs2_flags_update/fs/gfs2/ops_file.h
--- linux-2.6.21-rc6-4-ocfs2_flags_update/fs/gfs2/ops_file.h	2007-02-07 12:03:23.000000000 +0100
+++ linux-2.6.21-rc6-5-gfs2_flags_update/fs/gfs2/ops_file.h	2007-04-23 20:11:43.000000000 +0200
@@ -18,6 +18,7 @@ extern int gfs2_internal_read(struct gfs
 			      struct file_ra_state *ra_state,
 			      char *buf, loff_t *pos, unsigned size);
 extern void gfs2_set_inode_flags(struct inode *inode);
+extern void gfs2_get_inode_flags(struct gfs2_inode *inode);
 extern const struct file_operations gfs2_file_fops;
 extern const struct file_operations gfs2_dir_fops;
 
diff -rupX /home/jack/.kerndiffexclude linux-2.6.21-rc6-4-ocfs2_flags_update/include/linux/gfs2_ondisk.h linux-2.6.21-rc6-5-gfs2_flags_update/include/linux/gfs2_ondisk.h
--- linux-2.6.21-rc6-4-ocfs2_flags_update/include/linux/gfs2_ondisk.h	2007-04-23 20:25:17.000000000 +0200
+++ linux-2.6.21-rc6-5-gfs2_flags_update/include/linux/gfs2_ondisk.h	2007-04-23 20:25:42.000000000 +0200
@@ -519,7 +519,7 @@ extern void gfs2_rgrp_in(struct gfs2_rgr
 extern void gfs2_rgrp_out(const struct gfs2_rgrp_host *rg, void *buf);
 extern void gfs2_quota_in(struct gfs2_quota_host *qu, const void *buf);
 struct gfs2_inode;
-extern void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
+extern void gfs2_dinode_out(struct gfs2_inode *ip, void *buf);
 extern void gfs2_ea_header_in(struct gfs2_ea_header *ea, const void *buf);
 extern void gfs2_ea_header_out(const struct gfs2_ea_header *ea, void *buf);
 extern void gfs2_log_header_in(struct gfs2_log_header_host *lh, const void *buf);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]