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.
Lustre-change: https://review.whamcloud.com/52798
Lustre-commit: TBD (from
3dfe2d3abc6bff161ebce62736990fabe540c1de)
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I4c99f1d9f3962d46ebf9e9b799988ff3dba4f919
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52708
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
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;
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;