[LU-16465] truncate does not update the LSOM blocks correctly Created: 12/Jan/23  Updated: 25/Apr/23  Resolved: 22/Apr/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-14765 sanity-flr test_44c: mirror split doe... Open
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   
[root@client client]# touch test                                          
[root@client client]# dd if=/dev/zero of=test bs=1M count=2 conv=fsync    
2+0 records in                                                            
2+0 records out                                                           
2097152 bytes (2.1 MB) copied, 0.0265768 s, 78.9 MB/s                     
[root@client client]# lfs getsom test && stat test                        
file: test size: 2097152 blocks: 0 flags: 4                               
  File: ‘test’                                                            
  Size: 2097152         Blocks: 4096       IO Block: 4194304 regular file 
Device: 481510a2h/1209340066d   Inode: 144115205289279523  Links: 1       
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)  
Access: 2023-01-12 20:41:15.000000000 +0100                               
Modify: 2023-01-12 20:41:28.000000000 +0100                               
Change: 2023-01-12 20:41:28.000000000 +0100                               
 Birth: -                                                                 
[root@client client]# cat test                                            
[root@client client]# lfs getsom test && stat test                        
file: test size: 2097152 blocks: 4096 flags: 4                              <--- inode i_blocks are update by the open-close
  File: ‘test’                                                            
  Size: 2097152         Blocks: 4096       IO Block: 4194304 regular file 
Device: 481510a2h/1209340066d   Inode: 144115205289279523  Links: 1       
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)  
Access: 2023-01-12 20:41:39.000000000 +0100                               
Modify: 2023-01-12 20:41:28.000000000 +0100                               
Change: 2023-01-12 20:41:28.000000000 +0100                               
 Birth: -                                                                 
[root@client client]# truncate -s1K test                                  
[root@client client]# lfs getsom test && stat test                        
file: test size: 1024 blocks: 4096 flags: 4                                 <--- inode i_blocks are not update after the truncate, so close request sends the old value
  File: ‘test’                                                            
  Size: 1024            Blocks: 8          IO Block: 4194304 regular file 
Device: 481510a2h/1209340066d   Inode: 144115205289279523  Links: 1       
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)  
Access: 2023-01-12 20:41:39.000000000 +0100                               
Modify: 2023-01-12 20:42:27.000000000 +0100                               
Change: 2023-01-12 20:42:27.000000000 +0100                               
 Birth: -                                                                 
[root@client client]# cat test                                            
[root@client client]# lfs getsom test && stat test                        
file: test size: 1024 blocks: 4096 flags: 4                                 <---- MDT denies blocks update from the client (only truncate are allowed to decrease the blocks count).
  File: ‘test’                                                            
  Size: 1024            Blocks: 8          IO Block: 4194304 regular file 
Device: 481510a2h/1209340066d   Inode: 144115205289279523  Links: 1       
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)  
Access: 2023-01-12 20:42:56.000000000 +0100                               
Modify: 2023-01-12 20:42:27.000000000 +0100                               
Change: 2023-01-12 20:42:27.000000000 +0100                               
 Birth: -                                                                 

On the MDT:

int mdt_lsom_update(struct mdt_thread_info *info,       
                    struct mdt_object *o, bool truncate)
....
        if (!(la->la_valid & (LA_SIZE | LA_LSIZE) &&              
              o->mot_lsom_size < la->la_size) &&                  
            !(la->la_valid & (LA_BLOCKS | LA_LBLOCKS) &&          
              o->mot_lsom_blocks < la->la_blocks) && !truncate &&    <---- refuse to update LSOM from close request if new_blocks_value < old_blocks_value
            o->mot_lsom_inited)                                   
                RETURN(0);                                        
....


 Comments   
Comment by Gerrit Updater [ 18/Jan/23 ]

"Etienne AUJAMES <eaujames@ddn.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/49675
Subject: LU-16465 llite: fix LSOM blocks for ftruncate and close
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 00b2c5888959c81ec195bb5c853c948630aac13e

Comment by Gerrit Updater [ 11/Apr/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/49675/
Subject: LU-16465 llite: fix LSOM blocks for ftruncate and close
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: dfb08bbf77a1362f79c3738cc3952f8db2e46511

Comment by Gerrit Updater [ 11/Apr/23 ]

"Oleg Drokin <green@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/50606
Subject: LU-16465 tests: update sanity test 806 to use save/restore_opencache
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: bca8875bdb08e1c15fc46902b2dd5a215a4e33a5

Comment by Gerrit Updater [ 22/Apr/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/50606/
Subject: LU-16465 tests: update sanity test 806 to use save/restore_opencache
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 3ba223327f357f3da9ab81b6808422c4b0a9fbc3

Comment by Peter Jones [ 22/Apr/23 ]

Landed for 2.16

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