gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
PATCH 1/1 gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
When new files and directories are created inside a parent directory we automatically inherit the GFS2_DIF_SYSTEM flag (if set) and assign it to the new file/dirs.
All new system files/dirs created in the metafs by, say gfs2_jadd, will have this flag set because they will have parent directories in the metafs whose GFS2_DIF_SYSTEM flag has already been set (most likely by a previous mkfs.gfs2)
Resolves: rhbz#1272086
--- fs/gfs2/file.c | 4 ++-- fs/gfs2/inode.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)
fs/gfs2/file.c +2 -2
@@ -298,9 +298,9 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr) gfsflags &= ~GFS2_DIF_TOPDIR ;if (gfsflags &GFS2_DIF_INHERIT_JDATA ) gfsflags ^= (GFS2_DIF_JDATA |GFS2_DIF_INHERIT_JDATA ); -return do_gfs2_set_flags (filp, gfsflags, ~0 ); +return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_SYSTEM ); } -return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_JDATA ); +return do_gfs2_set_flags (filp, gfsflags, ~(GFS2_DIF_SYSTEM |GFS2_DIF_JDATA )); }static long gfs2_ioctl (struct file *filp,unsigned int cmd,unsigned long arg)
fs/gfs2/inode.c +5 -0
@@ -685,6 +685,11 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, ip->i_entries =2 ;break ; } + +/* Force SYSTEM flag on all files and subdirs of a SYSTEM directory */ +if (dip->i_diskflags &GFS2_DIF_SYSTEM ) + ip->i_diskflags |=GFS2_DIF_SYSTEM ; +gfs2_set_inode_flags (inode); if ((GFS2_I(d_inode(sdp->sd_root_dir)) == dip) ||
Signature · 1 line
2.4.3
PATCH 1/1 gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
----- Original Message -----
Quoted 51 lines
When new files and directories are created inside a parent directory we automatically inherit the
GFS2_DIF_SYSTEMflag (if set) and assign it to the new file/dirs.All new system files/dirs created in the metafs by, say
gfs2_jadd, will have this flag set because they will have parent directories in the metafs whoseGFS2_DIF_SYSTEMflag has already been set (most likely by a previous mkfs.gfs2)Resolves: rhbz#1272086
Signed-off-by Abhi Das <[email protected]>--- fs/gfs2/file.c | 4 ++-- fs/gfs2/inode.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)fs/gfs2/file.c +2
-2@@ -298,9 +298,9 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr) gfsflags &= ~GFS2_DIF_TOPDIR ;if (gfsflags &GFS2_DIF_INHERIT_JDATA ) gfsflags ^= (GFS2_DIF_JDATA |GFS2_DIF_INHERIT_JDATA ); -return do_gfs2_set_flags (filp, gfsflags, ~0 ); +return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_SYSTEM ); } -return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_JDATA ); +return do_gfs2_set_flags (filp, gfsflags, ~(GFS2_DIF_SYSTEM |GFS2_DIF_JDATA )); }static long
gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)fs/gfs2/inode.c +5
-0@@ -685,6 +685,11 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, ip->i_entries =2 ;break ; } + +/* Force SYSTEM flag on all files and subdirs of a SYSTEM directory */ +if (dip->i_diskflags &GFS2_DIF_SYSTEM ) + ip->i_diskflags |=GFS2_DIF_SYSTEM ; +gfs2_set_inode_flags (inode);
Quoted 5 lines
if ((GFS2_I(d_inode(sdp->sd_root_dir)) == dip) ||
--
2.4.3
Hi,
Looks good.
Regards,
Bob Peterson
Red Hat File Systems
PATCH 1/1 gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
In reply to Abhi DasHi Abhi,
Quoted 21 lines · Abhi Das
When new files and directories are created inside a parent directory we automatically inherit the
GFS2_DIF_SYSTEMflag (if set) and assign it to the new file/dirs.All new system files/dirs created in the metafs by, say
gfs2_jadd, will have this flag set because they will have parent directories in the metafs whoseGFS2_DIF_SYSTEMflag has already been set (most likely by a previous mkfs.gfs2)Resolves: rhbz#1272086
Signed-off-by Abhi Das <[email protected]>--- fs/gfs2/file.c | 4 ++-- fs/gfs2/inode.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)fs/gfs2/file.c +0
-0
fs/gfs2/file.c static int gfs2_set_flags(struct file *filp, u32 __user *ptr) · line 303
Quoted 8 lines
fs/gfs2/file.c +2
-2@@ -298,9 +298,9 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr) gfsflags &= ~GFS2_DIF_TOPDIR ;if (gfsflags &GFS2_DIF_INHERIT_JDATA ) gfsflags ^= (GFS2_DIF_JDATA |GFS2_DIF_INHERIT_JDATA ); -return do_gfs2_set_flags (filp, gfsflags, ~0 ); +return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_SYSTEM ); } -return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_JDATA ); +return do_gfs2_set_flags (filp, gfsflags, ~(GFS2_DIF_SYSTEM |GFS2_DIF_JDATA ));
Are these two changes still required? The function only seems to get called in the SETFLAGS ioctl path.
Cheers,
Andy
Quoted 20 lines
fs/gfs2/file.c +0
-0}static long gfs2_ioctl (struct file *filp,unsigned int cmd,unsigned long arg)fs/gfs2/inode.c +5
-0@@ -685,6 +685,11 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, ip->i_entries =2 ;break ; } + +/* Force SYSTEM flag on all files and subdirs of a SYSTEM directory */ +if (dip->i_diskflags &GFS2_DIF_SYSTEM ) + ip->i_diskflags |=GFS2_DIF_SYSTEM ; +gfs2_set_inode_flags (inode); if ((GFS2_I(d_inode(sdp->sd_root_dir)) == dip) ||
PATCH 1/1 gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
Hi Andy,
----- Original Message -----
Quoted 43 lines
From: "Andrew Price" <[email protected]>
To: "Abhi Das" <[email protected]>, cluster-devel at redhat.com
Sent: Thursday, November 5, 2015 12:19:48 PM
Subject: Re: [Cluster-devel] [GFS2 PATCH] gfs2: Automatically setGFS2_DIF_SYSTEMflag on system filesHi Abhi,
Quoted 21 lines · Abhi Das
When new files and directories are created inside a parent directory we automatically inherit the
GFS2_DIF_SYSTEMflag (if set) and assign it to the new file/dirs.All new system files/dirs created in the metafs by, say
gfs2_jadd, will have this flag set because they will have parent directories in the metafs whoseGFS2_DIF_SYSTEMflag has already been set (most likely by a previous mkfs.gfs2)Resolves: rhbz#1272086
Signed-off-by Abhi Das <[email protected]>--- fs/gfs2/file.c | 4 ++-- fs/gfs2/inode.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)fs/gfs2/file.c +0
-0fs/gfs2/file.c static int gfs2_set_flags(struct file *filp, u32 __user · line 305
Quoted 10 lines
fs/gfs2/file.c +2
-2@@ -298,9 +298,9 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr) gfsflags &= ~GFS2_DIF_TOPDIR ;if (gfsflags &GFS2_DIF_INHERIT_JDATA ) gfsflags ^= (GFS2_DIF_JDATA |GFS2_DIF_INHERIT_JDATA ); -return do_gfs2_set_flags (filp, gfsflags, ~0 ); +return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_SYSTEM ); } -return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_JDATA ); +return do_gfs2_set_flags (filp, gfsflags, ~(GFS2_DIF_SYSTEM |GFS2_DIF_JDATA ));Are these two changes still required? The function only seems to get called in the SETFLAGS ioctl path.
Quoted 3 lines
Cheers,
Andy
Yes. This 3rd argument to do_gfs2_set_flags() is a field mask and is used like this:
new_flags = (flags & ~mask) | (reqflags & mask);
Since the requested flags 'reqflags' from userspace (gfs2_jadd, for example) can't set GFS2_DIF_SYSTEM, only way to preserve this flag's value across SETFLAGS ioctls is to not touch it via the mask when it is ANDed with the existing flags 'flags'.
Hope that makes sense.
Cheers!
--Abhi
PATCH 1/1 gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
Quoted 53 lines · Abhijith Das
Hi Andy,
----- Original Message -----
Quoted 43 lines
From: "Andrew Price" <[email protected]>
To: "Abhi Das" <[email protected]>, cluster-devel at redhat.com
Sent: Thursday, November 5, 2015 12:19:48 PM
Subject: Re: [Cluster-devel] [GFS2 PATCH] gfs2: Automatically setGFS2_DIF_SYSTEMflag on system filesHi Abhi,
Quoted 21 lines · Abhi Das
When new files and directories are created inside a parent directory we automatically inherit the
GFS2_DIF_SYSTEMflag (if set) and assign it to the new file/dirs.All new system files/dirs created in the metafs by, say
gfs2_jadd, will have this flag set because they will have parent directories in the metafs whoseGFS2_DIF_SYSTEMflag has already been set (most likely by a previous mkfs.gfs2)Resolves: rhbz#1272086
Signed-off-by Abhi Das <[email protected]>--- fs/gfs2/file.c | 4 ++-- fs/gfs2/inode.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)fs/gfs2/file.c +0
-0fs/gfs2/file.c static int gfs2_set_flags(struct file *filp, u32 __user · line 305
Quoted 10 lines
fs/gfs2/file.c +2
-2@@ -298,9 +298,9 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr) gfsflags &= ~GFS2_DIF_TOPDIR ;if (gfsflags &GFS2_DIF_INHERIT_JDATA ) gfsflags ^= (GFS2_DIF_JDATA |GFS2_DIF_INHERIT_JDATA ); -return do_gfs2_set_flags (filp, gfsflags, ~0 ); +return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_SYSTEM ); } -return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_JDATA ); +return do_gfs2_set_flags (filp, gfsflags, ~(GFS2_DIF_SYSTEM |GFS2_DIF_JDATA ));Are these two changes still required? The function only seems to get called in the SETFLAGS ioctl path.
Quoted 3 lines
Cheers,
AndyYes. This 3rd argument to
do_gfs2_set_flags()is a field mask and is used like this:
Quoted 7 lines
new_flags= (flags & ~mask) | (reqflags & mask);Since the requested flags 'reqflags' from userspace (
gfs2_jadd, for example) can't setGFS2_DIF_SYSTEM, only way to preserve this flag's value across SETFLAGS ioctls is to not touch it via the mask when it is ANDed with the existing flags 'flags'.Hope that makes sense.
It does, thanks!
Andy
PATCH 1/1 gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
In reply to Abhi Das----- Original Message -----
Quoted 51 lines
When new files and directories are created inside a parent directory we automatically inherit the
GFS2_DIF_SYSTEMflag (if set) and assign it to the new file/dirs.All new system files/dirs created in the metafs by, say
gfs2_jadd, will have this flag set because they will have parent directories in the metafs whoseGFS2_DIF_SYSTEMflag has already been set (most likely by a previous mkfs.gfs2)Resolves: rhbz#1272086
Signed-off-by Abhi Das <[email protected]>--- fs/gfs2/file.c | 4 ++-- fs/gfs2/inode.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)fs/gfs2/file.c +2
-2@@ -298,9 +298,9 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr) gfsflags &= ~GFS2_DIF_TOPDIR ;if (gfsflags &GFS2_DIF_INHERIT_JDATA ) gfsflags ^= (GFS2_DIF_JDATA |GFS2_DIF_INHERIT_JDATA ); -return do_gfs2_set_flags (filp, gfsflags, ~0 ); +return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_SYSTEM ); } -return do_gfs2_set_flags (filp, gfsflags, ~GFS2_DIF_JDATA ); +return do_gfs2_set_flags (filp, gfsflags, ~(GFS2_DIF_SYSTEM |GFS2_DIF_JDATA )); }static long
gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)fs/gfs2/inode.c +5
-0@@ -685,6 +685,11 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, ip->i_entries =2 ;break ; } + +/* Force SYSTEM flag on all files and subdirs of a SYSTEM directory */ +if (dip->i_diskflags &GFS2_DIF_SYSTEM ) + ip->i_diskflags |=GFS2_DIF_SYSTEM ; +gfs2_set_inode_flags (inode);
Quoted 5 lines
if ((GFS2_I(d_inode(sdp->sd_root_dir)) == dip) ||
--
2.4.3
Hi,
Thanks. This is now applied to the for-next branch of the linux-gfs2 tree:
https://git.kernel.org/cgit/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next&id=acc546fd6108cb17f87f985e4235b68756d7b01f
Regards,
Bob Peterson
Red Hat File Systems