All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
@ 2015-10-30 19:57 Abhi Das
  2015-11-05 17:56 ` Bob Peterson
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Abhi Das @ 2015-10-30 19:57 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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
Signed-off-by: Abhi Das <adas@redhat.com>
---
 fs/gfs2/file.c  | 4 ++--
 fs/gfs2/inode.c | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 71cd138..63fe948 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -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)
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 063fdfc..2c05bc3 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -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) ||
-- 
2.4.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
  2015-10-30 19:57 [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files Abhi Das
@ 2015-11-05 17:56 ` Bob Peterson
  2015-11-05 18:19 ` Andrew Price
  2015-11-10 21:13 ` Bob Peterson
  2 siblings, 0 replies; 6+ messages in thread
From: Bob Peterson @ 2015-11-05 17:56 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
> 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
> Signed-off-by: Abhi Das <adas@redhat.com>
> ---
>  fs/gfs2/file.c  | 4 ++--
>  fs/gfs2/inode.c | 5 +++++
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index 71cd138..63fe948 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -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)
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index 063fdfc..2c05bc3 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -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) ||
> --
> 2.4.3
> 
> 

Hi,

Looks good.
Acked-by: Bob Peterson <rpeterso@redhat.com>

Regards,

Bob Peterson
Red Hat File Systems



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
  2015-10-30 19:57 [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files Abhi Das
  2015-11-05 17:56 ` Bob Peterson
@ 2015-11-05 18:19 ` Andrew Price
  2015-11-05 18:40   ` Abhijith Das
  2015-11-10 21:13 ` Bob Peterson
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Price @ 2015-11-05 18:19 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi Abhi,

On 30/10/15 19:57, Abhi Das wrote:
> 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
> Signed-off-by: Abhi Das <adas@redhat.com>
> ---
>   fs/gfs2/file.c  | 4 ++--
>   fs/gfs2/inode.c | 5 +++++
>   2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index 71cd138..63fe948 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -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

>   }
>
>   static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index 063fdfc..2c05bc3 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -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) ||
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
  2015-11-05 18:19 ` Andrew Price
@ 2015-11-05 18:40   ` Abhijith Das
  2015-11-05 19:03     ` Andrew Price
  0 siblings, 1 reply; 6+ messages in thread
From: Abhijith Das @ 2015-11-05 18:40 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi Andy,

----- Original Message -----
> From: "Andrew Price" <anprice@redhat.com>
> To: "Abhi Das" <adas@redhat.com>, cluster-devel at redhat.com
> Sent: Thursday, November 5, 2015 12:19:48 PM
> Subject: Re: [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
> 
> Hi Abhi,
> 
> On 30/10/15 19:57, Abhi Das wrote:
> > 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
> > Signed-off-by: Abhi Das <adas@redhat.com>
> > ---
> >   fs/gfs2/file.c  | 4 ++--
> >   fs/gfs2/inode.c | 5 +++++
> >   2 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> > index 71cd138..63fe948 100644
> > --- a/fs/gfs2/file.c
> > +++ b/fs/gfs2/file.c
> > @@ -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
> 

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
  2015-11-05 18:40   ` Abhijith Das
@ 2015-11-05 19:03     ` Andrew Price
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Price @ 2015-11-05 19:03 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 05/11/15 18:40, Abhijith Das wrote:
> Hi Andy,
>
> ----- Original Message -----
>> From: "Andrew Price" <anprice@redhat.com>
>> To: "Abhi Das" <adas@redhat.com>, cluster-devel at redhat.com
>> Sent: Thursday, November 5, 2015 12:19:48 PM
>> Subject: Re: [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
>>
>> Hi Abhi,
>>
>> On 30/10/15 19:57, Abhi Das wrote:
>>> 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
>>> Signed-off-by: Abhi Das <adas@redhat.com>
>>> ---
>>>    fs/gfs2/file.c  | 4 ++--
>>>    fs/gfs2/inode.c | 5 +++++
>>>    2 files changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
>>> index 71cd138..63fe948 100644
>>> --- a/fs/gfs2/file.c
>>> +++ b/fs/gfs2/file.c
>>> @@ -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
>>
>
> 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.

It does, thanks!

Andy



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files
  2015-10-30 19:57 [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files Abhi Das
  2015-11-05 17:56 ` Bob Peterson
  2015-11-05 18:19 ` Andrew Price
@ 2015-11-10 21:13 ` Bob Peterson
  2 siblings, 0 replies; 6+ messages in thread
From: Bob Peterson @ 2015-11-10 21:13 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
> 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
> Signed-off-by: Abhi Das <adas@redhat.com>
> ---
>  fs/gfs2/file.c  | 4 ++--
>  fs/gfs2/inode.c | 5 +++++
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index 71cd138..63fe948 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -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)
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index 063fdfc..2c05bc3 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -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) ||
> --
> 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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-11-10 21:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-30 19:57 [Cluster-devel] [GFS2 PATCH] gfs2: Automatically set GFS2_DIF_SYSTEM flag on system files Abhi Das
2015-11-05 17:56 ` Bob Peterson
2015-11-05 18:19 ` Andrew Price
2015-11-05 18:40   ` Abhijith Das
2015-11-05 19:03     ` Andrew Price
2015-11-10 21:13 ` Bob Peterson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.