Whamcloud - gitweb
EX-7600 osd: save compressed object size on zfs
authorArtem Blagodarenko <ablagodarenko@whamcloud.com>
Thu, 2 Nov 2023 22:20:52 +0000 (22:20 +0000)
committerAndreas Dilger <adilger@whamcloud.com>
Mon, 27 Nov 2023 18:36:17 +0000 (18:36 +0000)
"osc: save compressed object size" added means to transfer
object size to the osd and added ldiskfs support.

This patch adds saving objec size to the ZFS backend.
Currently this fix submitted as separete patch, for
testing purpouse, but can be marged to the main patch latter.

Signed-off-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Test-Parameters: trivial testlist=sanity fstype=zfs
Change-Id: I99e29e3f756a070b5f3cece12c4ca58f668a2ecf
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52958
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/osd-zfs/osd_io.c

index b183a1e..09d3198 100644 (file)
@@ -827,6 +827,7 @@ static int osd_write_commit(const struct lu_env *env, struct dt_object *dt,
        uint64_t            new_size = 0;
        int                 i, abufsz, rc = 0, drop_cache = 0;
        unsigned long      iosize = 0;
+       bool compressed = false;
        ENTRY;
 
        LASSERT(dt_object_exists(dt));
@@ -894,6 +895,8 @@ static int osd_write_commit(const struct lu_env *env, struct dt_object *dt,
                        continue;
                }
 
+               compressed |= lnb[i].lnb_flags & OBD_BRW_COMPRESSED;
+
                if (new_size < lnb[i].lnb_file_offset + lnb[i].lnb_len)
                        new_size = lnb[i].lnb_file_offset + lnb[i].lnb_len;
                if (lnb[i].lnb_page == NULL)
@@ -958,6 +961,14 @@ static int osd_write_commit(const struct lu_env *env, struct dt_object *dt,
        /* if file has grown, take user_size into account */
        if (user_size && new_size > user_size)
                new_size = user_size;
+       /*
+        * Compressed files can have holes at the
+        * object's end. This is required for correct
+        * file size.
+        */
+       if (compressed && user_size > new_size)
+               new_size = user_size;
+
        write_lock(&obj->oo_attr_lock);
        if (obj->oo_attr.la_size < new_size) {
                obj->oo_attr.la_size = new_size;