[LU-16463] llapi_open_by_fid open should not be cached systematically Created: 12/Jan/23  Updated: 03/Jul/23  Resolved: 23/Feb/23

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.16.0

Type: Bug Priority: Minor
Reporter: Etienne Aujames Assignee: Etienne Aujames
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Related
is related to LU-8585 All Lustre test suites should pass wi... Open
is related to LU-10948 client cache open lock after N opens Open
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

llapi_open_by_fid() uses open_by_handle_at() since https://review.whamcloud.com/36603 ("LU-8585 llapi: use open_by_handle_at in llapi_open_by_fid"). But handle are used by NFS and cache open in that case to limit the number of open-close (close are sent to MDT only on lock conflict or cache shrinks, http://review.whamcloud.com/20354).

This breaks the llsom_sync util, because it used llapi_open_by_fid and "trusted.som" xattrs are synchronized on close requests:

[root@client client]# touch test                                                
[root@client client]# dd if=/dev/zero of=test bs=1M count=1                     
1+0 records in                                                                  
1+0 records out                                                                 
1048576 bytes (1.0 MB) copied, 0.00145669 s, 720 MB/s                           
[root@client client]# lfs getsom test && stat test                              
file: test size: 1048576 blocks: 0 flags: 4                                     
  File: ‘test’                                                                  
  Size: 1048576         Blocks: 2048       IO Block: 4194304 regular file       
Device: 481510a2h/1209340066d   Inode: 144115205507383305  Links: 1             
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)        
Access: 2023-01-12 11:22:03.000000000 +0100                                     
Modify: 2023-01-12 11:22:07.000000000 +0100                                     
Change: 2023-01-12 11:22:07.000000000 +0100                                     
 Birth: -                                                                       
[root@client client]# cat test                                                                      
[root@client client]# lfs getsom test && stat test                                                  
file: test size: 1048576 blocks: 2048 flags: 4                                                      <----  updated
  File: ‘test’                                                                                      
  Size: 1048576         Blocks: 2048       IO Block: 4194304 regular file                           
Device: 481510a2h/1209340066d   Inode: 144115205507383305  Links: 1                                 
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)                            
Access: 2023-01-12 11:22:27.000000000 +0100                                                         
Modify: 2023-01-12 11:22:07.000000000 +0100                                                         
Change: 2023-01-12 11:22:07.000000000 +0100                                                         
 Birth: -                                                                                           
[root@client client]# dd if=/dev/zero of=test bs=1M count=2 conv=notrunc                            
2+0 records in                                                                                      
2+0 records out                                                                                     
2097152 bytes (2.1 MB) copied, 0.00210231 s, 998 MB/s                                               
[root@client client]# lfs getsom test && stat test                                                  
file: test size: 2097152 blocks: 2048 flags: 4                                                      
  File: ‘test’                                                                                      
  Size: 2097152         Blocks: 4096       IO Block: 4194304 regular file                           
Device: 481510a2h/1209340066d   Inode: 144115205507383305  Links: 1                                 
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)                            
Access: 2023-01-12 11:22:27.000000000 +0100                                                         
Modify: 2023-01-12 11:23:02.000000000 +0100                                                         
Change: 2023-01-12 11:23:02.000000000 +0100                                                         
 Birth: -                                                                                           
[root@client client]# llsom_sync -u cl11 -m lustrefs-MDT0000 /media/lustrefs/client                 
Start to sync 1 records.                                                                            
[root@client client]# lfs getsom test && stat test                                                  
file: test size: 2097152 blocks: 2048 flags: 4                                                       <---- not updated
  File: ‘test’                                                                                      
  Size: 2097152         Blocks: 4096       IO Block: 4194304 regular file                           
Device: 481510a2h/1209340066d   Inode: 144115205507383305  Links: 1                                 
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)                            
Access: 2023-01-12 11:22:27.000000000 +0100                                                         
Modify: 2023-01-12 11:23:02.000000000 +0100                                                         
Change: 2023-01-12 11:23:02.000000000 +0100                                                         
 Birth: -                                                                                           
[root@client client]# cat test                                                                      
[root@client client]# lfs getsom test && stat test                                                  
file: test size: 2097152 blocks: 2048 flags: 4                                                      <---- not updated
  File: ‘test’                                                                                      
  Size: 2097152         Blocks: 4096       IO Block: 4194304 regular file                           
Device: 481510a2h/1209340066d   Inode: 144115205507383305  Links: 1                                 
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)                            
Access: 2023-01-12 11:24:29.000000000 +0100                                                         
Modify: 2023-01-12 11:23:02.000000000 +0100                                                         
Change: 2023-01-12 11:23:02.000000000 +0100                                                         
 Birth: -                                                                                           

This is not seen by "sanity test 807" because https://review.whamcloud.com/32158 "LU-10948 llite: Introduce inode open heat counter" clears lock caches before calling "lfs getsom" (in check_lsom_data/check_lsom_size).



 Comments   
Comment by James A Simmons [ 12/Jan/23 ]

Can you try patch https://review.whamcloud.com/#/c/fs/lustre-release/+/49237

Comment by Etienne Aujames [ 12/Jan/23 ]

Can you try patch https://review.whamcloud.com/#/c/fs/lustre-release/+/49237

I have read the patch, that should work.
I was working on the following patch to avoid caching opens only for llapi_open_by_fid().

Comment by Gerrit Updater [ 12/Jan/23 ]

"Etienne AUJAMES <eaujames@ddn.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/49616
Subject: LU-16463 llite: fix the opencache for llapi_open_by_fid()
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 49d440cd9132d799a98e3264494015e3faaa4fba

Comment by James A Simmons [ 12/Jan/23 ]

Personally I like to see us move away from opencache since its rarely needed anymore. Let me update my patch. Now I don't like your idea of using a flag I could see passing in an open count limit. By default it would be zero but it would allow the user to cache the open if they wanted after a certain open count. That would be powerful.

Comment by Gerrit Updater [ 23/Feb/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/49237/
Subject: LU-16463 llite: replace lld_nfs_dentry flag with opencache handling
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: d7a85652f4fcb83192262cfc1a0211890f404c7c

Comment by Peter Jones [ 23/Feb/23 ]

Landed for 2.16

Comment by Gerrit Updater [ 03/Jul/23 ]

"Etienne AUJAMES <eaujames@ddn.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51540
Subject: LU-16463 llite: replace lld_nfs_dentry flag with opencache handling
Project: fs/lustre-release
Branch: b2_15
Current Patch Set: 1
Commit: 8851053466b545039d6719a39d9726066c651b82

Generated at Sat Feb 10 03:27:14 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.