From 6178714715d8886334d98e065ded6bdf2212287d Mon Sep 17 00:00:00 2001 From: Artem Blagodarenko Date: Thu, 2 Nov 2023 22:20:52 +0000 Subject: [PATCH] EX-7600 osd: save compressed object size on zfs "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 Test-Parameters: trivial testlist=sanity fstype=zfs Change-Id: I99e29e3f756a070b5f3cece12c4ca58f668a2ecf Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52958 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger --- lustre/osd-zfs/osd_io.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lustre/osd-zfs/osd_io.c b/lustre/osd-zfs/osd_io.c index b183a1e..09d3198 100644 --- a/lustre/osd-zfs/osd_io.c +++ b/lustre/osd-zfs/osd_io.c @@ -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; -- 1.8.3.1