diff mbox series

ocfs2: drop acl cache for directories too

Message ID 20210903012631.6099-1-wen.gang.wang@oracle.com (mailing list archive)
State New, archived
Headers show
Series ocfs2: drop acl cache for directories too | expand

Commit Message

Wengang Wang Sept. 3, 2021, 1:26 a.m. UTC
ocfs2_data_convert_worker() is currently dropping any cached acl info
for FILE before down-converting meta lock. It should also drop for DIRECTORY.
Otherwise the second acl lookup returns the cached one (from VFS layer) which
could be already stale.

The problem we are seeing is that the acl changes on one node doesn't get
refreshed on other nodes in the following case:

  Node 1                    Node 2
--------------            ----------------
getfacl dir1

			  getfacl dir1    <-- this is OK

setfacl -m u:user1:rwX dir1
getfacl dir1   <-- see the change for user1

			  getfacl dir1    <-- can't see change for user1

Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
---
 fs/ocfs2/dlmglue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Greg KH Sept. 3, 2021, 4:54 a.m. UTC | #1
On Thu, Sep 02, 2021 at 06:26:31PM -0700, Wengang Wang wrote:
> ocfs2_data_convert_worker() is currently dropping any cached acl info
> for FILE before down-converting meta lock. It should also drop for DIRECTORY.
> Otherwise the second acl lookup returns the cached one (from VFS layer) which
> could be already stale.
> 
> The problem we are seeing is that the acl changes on one node doesn't get
> refreshed on other nodes in the following case:
> 
>   Node 1                    Node 2
> --------------            ----------------
> getfacl dir1
> 
> 			  getfacl dir1    <-- this is OK
> 
> setfacl -m u:user1:rwX dir1
> getfacl dir1   <-- see the change for user1
> 
> 			  getfacl dir1    <-- can't see change for user1
> 
> Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
> ---
>  fs/ocfs2/dlmglue.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
> index 50a863fc1779..207ec61569ea 100644
> --- a/fs/ocfs2/dlmglue.c
> +++ b/fs/ocfs2/dlmglue.c
> @@ -3933,7 +3933,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
>  		oi = OCFS2_I(inode);
>  		oi->ip_dir_lock_gen++;
>  		mlog(0, "generation: %u\n", oi->ip_dir_lock_gen);
> -		goto out;
> +		goto out_forget;
>  	}
>  
>  	if (!S_ISREG(inode->i_mode))
> @@ -3964,6 +3964,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
>  		filemap_fdatawait(mapping);
>  	}
>  
> +out_forget:
>  	forget_all_cached_acls(inode);
>  
>  out:
> -- 
> 2.21.0 (Apple Git-122.2)
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>
Joseph Qi Sept. 6, 2021, 11:42 a.m. UTC | #2
On 9/3/21 9:26 AM, Wengang Wang wrote:
> ocfs2_data_convert_worker() is currently dropping any cached acl info
> for FILE before down-converting meta lock. It should also drop for DIRECTORY.
> Otherwise the second acl lookup returns the cached one (from VFS layer) which
> could be already stale.
> 
> The problem we are seeing is that the acl changes on one node doesn't get
> refreshed on other nodes in the following case:
> 
>   Node 1                    Node 2
> --------------            ----------------
> getfacl dir1
> 
> 			  getfacl dir1    <-- this is OK
> 
> setfacl -m u:user1:rwX dir1
> getfacl dir1   <-- see the change for user1
> 
> 			  getfacl dir1    <-- can't see change for user1
> 
> Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>

Looks sane to me.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> ---
>  fs/ocfs2/dlmglue.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
> index 50a863fc1779..207ec61569ea 100644
> --- a/fs/ocfs2/dlmglue.c
> +++ b/fs/ocfs2/dlmglue.c
> @@ -3933,7 +3933,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
>  		oi = OCFS2_I(inode);
>  		oi->ip_dir_lock_gen++;
>  		mlog(0, "generation: %u\n", oi->ip_dir_lock_gen);
> -		goto out;
> +		goto out_forget;
>  	}
>  
>  	if (!S_ISREG(inode->i_mode))
> @@ -3964,6 +3964,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
>  		filemap_fdatawait(mapping);
>  	}
>  
> +out_forget:
>  	forget_all_cached_acls(inode);
>  
>  out:
>
Wengang Wang Sept. 17, 2021, 4:46 p.m. UTC | #3
Hi Andrew,

Can you pls merge this patch if it’s not already on the way?

thanks,
wengang

On Sep 6, 2021, at 4:42 AM, Joseph Qi <joseph.qi@linux.alibaba.com<mailto:joseph.qi@linux.alibaba.com>> wrote:



On 9/3/21 9:26 AM, Wengang Wang wrote:
ocfs2_data_convert_worker() is currently dropping any cached acl info
for FILE before down-converting meta lock. It should also drop for DIRECTORY.
Otherwise the second acl lookup returns the cached one (from VFS layer) which
could be already stale.

The problem we are seeing is that the acl changes on one node doesn't get
refreshed on other nodes in the following case:

 Node 1                    Node 2
--------------            ----------------
getfacl dir1

  getfacl dir1    <-- this is OK

setfacl -m u:user1:rwX dir1
getfacl dir1   <-- see the change for user1

  getfacl dir1    <-- can't see change for user1

Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com<mailto:wen.gang.wang@oracle.com>>

Looks sane to me.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com<mailto:joseph.qi@linux.alibaba.com>>

---
fs/ocfs2/dlmglue.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 50a863fc1779..207ec61569ea 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -3933,7 +3933,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
oi = OCFS2_I(inode);
oi->ip_dir_lock_gen++;
mlog(0, "generation: %u\n", oi->ip_dir_lock_gen);
- goto out;
+ goto out_forget;
}

if (!S_ISREG(inode->i_mode))
@@ -3964,6 +3964,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
filemap_fdatawait(mapping);
}

+out_forget:
forget_all_cached_acls(inode);

out:
Joseph Qi Sept. 18, 2021, 2:43 a.m. UTC | #4
It has already been added in -mm tree.

Thanks,
Joseph

On 9/18/21 12:46 AM, Wengang Wang wrote:
> Hi Andrew,
> 
> Can you pls merge this patch if it’s not already on the way?
> 
> thanks,
> wengang
> 
> On Sep 6, 2021, at 4:42 AM, Joseph Qi <joseph.qi@linux.alibaba.com<mailto:joseph.qi@linux.alibaba.com>> wrote:
> 
> 
> 
> On 9/3/21 9:26 AM, Wengang Wang wrote:
> ocfs2_data_convert_worker() is currently dropping any cached acl info
> for FILE before down-converting meta lock. It should also drop for DIRECTORY.
> Otherwise the second acl lookup returns the cached one (from VFS layer) which
> could be already stale.
> 
> The problem we are seeing is that the acl changes on one node doesn't get
> refreshed on other nodes in the following case:
> 
>  Node 1                    Node 2
> --------------            ----------------
> getfacl dir1
> 
>   getfacl dir1    <-- this is OK
> 
> setfacl -m u:user1:rwX dir1
> getfacl dir1   <-- see the change for user1
> 
>   getfacl dir1    <-- can't see change for user1
> 
> Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com<mailto:wen.gang.wang@oracle.com>>
> 
> Looks sane to me.
> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com<mailto:joseph.qi@linux.alibaba.com>>
> 
> ---
> fs/ocfs2/dlmglue.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
> index 50a863fc1779..207ec61569ea 100644
> --- a/fs/ocfs2/dlmglue.c
> +++ b/fs/ocfs2/dlmglue.c
> @@ -3933,7 +3933,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
> oi = OCFS2_I(inode);
> oi->ip_dir_lock_gen++;
> mlog(0, "generation: %u\n", oi->ip_dir_lock_gen);
> - goto out;
> + goto out_forget;
> }
> 
> if (!S_ISREG(inode->i_mode))
> @@ -3964,6 +3964,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
> filemap_fdatawait(mapping);
> }
> 
> +out_forget:
> forget_all_cached_acls(inode);
> 
> out:
>
Wengang Wang Sept. 20, 2021, 3:36 p.m. UTC | #5
> On Sep 17, 2021, at 7:43 PM, Joseph Qi <joseph.qi@linux.alibaba.com> wrote:
> 
> It has already been added in -mm tree.

thanks!
wengang

> 
> Thanks,
> Joseph
> 
> On 9/18/21 12:46 AM, Wengang Wang wrote:
>> Hi Andrew,
>> 
>> Can you pls merge this patch if it’s not already on the way?
>> 
>> thanks,
>> wengang
>> 
>> On Sep 6, 2021, at 4:42 AM, Joseph Qi <joseph.qi@linux.alibaba.com<mailto:joseph.qi@linux.alibaba.com>> wrote:
>> 
>> 
>> 
>> On 9/3/21 9:26 AM, Wengang Wang wrote:
>> ocfs2_data_convert_worker() is currently dropping any cached acl info
>> for FILE before down-converting meta lock. It should also drop for DIRECTORY.
>> Otherwise the second acl lookup returns the cached one (from VFS layer) which
>> could be already stale.
>> 
>> The problem we are seeing is that the acl changes on one node doesn't get
>> refreshed on other nodes in the following case:
>> 
>> Node 1                    Node 2
>> --------------            ----------------
>> getfacl dir1
>> 
>>  getfacl dir1    <-- this is OK
>> 
>> setfacl -m u:user1:rwX dir1
>> getfacl dir1   <-- see the change for user1
>> 
>>  getfacl dir1    <-- can't see change for user1
>> 
>> Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com<mailto:wen.gang.wang@oracle.com>>
>> 
>> Looks sane to me.
>> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com<mailto:joseph.qi@linux.alibaba.com>>
>> 
>> ---
>> fs/ocfs2/dlmglue.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
>> index 50a863fc1779..207ec61569ea 100644
>> --- a/fs/ocfs2/dlmglue.c
>> +++ b/fs/ocfs2/dlmglue.c
>> @@ -3933,7 +3933,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
>> oi = OCFS2_I(inode);
>> oi->ip_dir_lock_gen++;
>> mlog(0, "generation: %u\n", oi->ip_dir_lock_gen);
>> - goto out;
>> + goto out_forget;
>> }
>> 
>> if (!S_ISREG(inode->i_mode))
>> @@ -3964,6 +3964,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
>> filemap_fdatawait(mapping);
>> }
>> 
>> +out_forget:
>> forget_all_cached_acls(inode);
>> 
>> out:
>>
diff mbox series

Patch

diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 50a863fc1779..207ec61569ea 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -3933,7 +3933,7 @@  static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
 		oi = OCFS2_I(inode);
 		oi->ip_dir_lock_gen++;
 		mlog(0, "generation: %u\n", oi->ip_dir_lock_gen);
-		goto out;
+		goto out_forget;
 	}
 
 	if (!S_ISREG(inode->i_mode))
@@ -3964,6 +3964,7 @@  static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
 		filemap_fdatawait(mapping);
 	}
 
+out_forget:
 	forget_all_cached_acls(inode);
 
 out: