]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/fs-io.c
Update bcachefs sources to 1a510b00b6 bcachefs: Increase BTREE_TRANS_MEM_MAX
[bcachefs-tools-debian] / libbcachefs / fs-io.c
index 0fbfa622586ecf14f36cfe559032ad28b4e1b892..b6eaaa0dd67c71d95daef56bf619d2c543ba781d 100644 (file)
@@ -2307,16 +2307,17 @@ int bch2_truncate(struct user_namespace *mnt_userns,
        int ret = 0;
 
        /*
-        * Don't update timestamps if we're not doing anything:
+        * If the truncate call with change the size of the file, the
+        * cmtimes should be updated. If the size will not change, we
+        * do not need to update the cmtimes.
         */
-       if (iattr->ia_size == inode->v.i_size)
-               return 0;
-
-       if (!(iattr->ia_valid & ATTR_MTIME))
-               ktime_get_coarse_real_ts64(&iattr->ia_mtime);
-       if (!(iattr->ia_valid & ATTR_CTIME))
-               ktime_get_coarse_real_ts64(&iattr->ia_ctime);
-       iattr->ia_valid |= ATTR_MTIME|ATTR_CTIME;
+       if (iattr->ia_size != inode->v.i_size) {
+               if (!(iattr->ia_valid & ATTR_MTIME))
+                       ktime_get_coarse_real_ts64(&iattr->ia_mtime);
+               if (!(iattr->ia_valid & ATTR_CTIME))
+                       ktime_get_coarse_real_ts64(&iattr->ia_ctime);
+               iattr->ia_valid |= ATTR_MTIME|ATTR_CTIME;
+       }
 
        inode_dio_wait(&inode->v);
        bch2_pagecache_block_get(&inode->ei_pagecache_lock);