Whamcloud - gitweb
LU-17218 ofd: improve filter_fid upgrade compatibility 98/52798/8
authorBobi Jam <bobijam@whamcloud.com>
Mon, 23 Oct 2023 07:29:07 +0000 (15:29 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 23 Apr 2024 19:45:14 +0000 (19:45 +0000)
filter_fid could be expanded in later Lustre version, and with
upgrade then downgrade process, the filter_fid EA on disk
could has been expanded during upgrade, and won't work after
the downgrade.

This patch improves this process by allocating bigger buffer to
hold the expanded filter_fid EA then trims the unrecognizable
fileds off.

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I4c99f1d9f3962d46ebf9e9b799988ff3dba4f919
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52798
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Qian Yingjin <qian@ddn.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
lustre/ofd/ofd_internal.h
lustre/ofd/ofd_objects.c

index 55e1639..688c332 100644 (file)
@@ -179,6 +179,13 @@ static inline char *ofd_name(struct ofd_device *ofd)
        return ofd->ofd_dt_dev.dd_lu_dev.ld_obd->obd_name;
 }
 
+/**
+ * for compatibility, filter_fid could occupy more space in newer version and
+ * downgraded Lustre would fail reading it with -ERANGE, so it can read it
+ * again with more space to hold it.
+ */
+#define FILTER_FID_EXTRA_SIZE  32
+
 struct ofd_object {
        struct lu_object_header ofo_header;
        struct dt_object        ofo_obj;
index fe74fa1..a3cdad5 100644 (file)
@@ -145,6 +145,20 @@ int ofd_object_ff_load(const struct lu_env *env, struct ofd_object *fo)
        buf->lb_buf = ff;
        buf->lb_len = sizeof(*ff);
        rc = dt_xattr_get(env, ofd_object_child(fo), buf, XATTR_NAME_FID);
+       if (rc == -ERANGE) {
+               struct filter_fid *ff_new;
+
+               OBD_ALLOC(ff_new, sizeof(*ff) + FILTER_FID_EXTRA_SIZE);
+               if (!ff_new)
+                       return -ENOMEM;
+               buf->lb_buf = ff_new;
+               buf->lb_len = sizeof(*ff) + FILTER_FID_EXTRA_SIZE;
+               rc = dt_xattr_get(env, ofd_object_child(fo), buf,
+                                 XATTR_NAME_FID);
+               if (rc > 0)
+                       memcpy(ff, ff_new, sizeof(*ff));
+               OBD_FREE(ff_new, sizeof(*ff) + FILTER_FID_EXTRA_SIZE);
+       }
        if (rc < 0)
                return rc;