Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-16465

truncate does not update the LSOM blocks correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • Lustre 2.16.0
    • None
    • None
    • 3
    • 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);                                        
      ....
      

      Attachments

        Issue Links

          Activity

            People

              eaujames Etienne Aujames
              eaujames Etienne Aujames
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: