From: Bobi Jam Date: Fri, 22 Mar 2024 07:49:21 +0000 (+0800) Subject: EX-9372 lpurge: rid of dup layout get X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7f6b12988ecd6bb707c6f7010f350e2cd9690ba1;p=fs%2Flustre-release.git EX-9372 lpurge: rid of dup layout get Delete the unnecessary lpurge_mirror_delete() repeat layout getting code, and update fd/fdv open flags align with LU-14677 to allow layout operations on encrypted files, even when the encryption key is not available. Signed-off-by: Bobi Jam Change-Id: If4e6e3a9c46ab782f08e5bc5b3710339af051719 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54527 Tested-by: jenkins Tested-by: Alexandre Ioffe Tested-by: Maloo Reviewed-by: Alexandre Ioffe Reviewed-by: Andreas Dilger --- diff --git a/lipe/src/lpurge.c b/lipe/src/lpurge.c index 240a43f..2b72e1e 100644 --- a/lipe/src/lpurge.c +++ b/lipe/src/lpurge.c @@ -940,7 +940,11 @@ lpurge_mirror_delete(const struct lu_fid *_fid, unsigned int mirror_id) snprintf(fid_buf, sizeof(fid_buf), DFID, PFID(&fid)); - fd = openat(open_by_fid_fd, fid_buf, O_RDWR); + /* allow mirror split even w/o the key on encrypted files, and in this + * case of a 'split -d', open file with O_DIRECT (no IOs will be done). + * refer to LU-14677 + */ + fd = openat(open_by_fid_fd, fid_buf, O_RDWR | O_DIRECT | O_CIPHERTEXT); if (fd < 0) { rc = -errno; LX_DEBUG("cannot open "DFID" for split: %s\n", @@ -956,7 +960,12 @@ lpurge_mirror_delete(const struct lu_fid *_fid, unsigned int mirror_id) mdt_index, (unsigned int)random()); vfd = openat(open_by_fid_fd, vname_buf, - O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_LOV_DELAY_CREATE); + O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW| + /* O_DIRECT for mirror split -d */ + O_DIRECT | + /* allow split w/o the key */ + O_CIPHERTEXT | + (O_LOV_DELAY_CREATE & ~O_ACCMODE)); if (vfd < 0) { rc = -errno; goto out; @@ -966,17 +975,6 @@ lpurge_mirror_delete(const struct lu_fid *_fid, unsigned int mirror_id) if (rc < 0) goto out; - layout = llapi_layout_get_by_fd(fd, 0); - if (layout == NULL) { - rc = -errno; - goto out; - } - - if (last_non_stale_mirror(mirror_id, layout)) { - rc = -EUCLEAN; - goto out; - } - lil = xcalloc(1, offsetof(typeof(*lil), lil_ids[2])); lil->lil_mode = LL_LEASE_UNLCK; lil->lil_flags = LL_LEASE_LAYOUT_SPLIT; @@ -1003,7 +1001,8 @@ out: LX_DEBUG("deleted mirror %u of "DFID"\n", mirror_id, PFID(&fid)); out1: - llapi_layout_free(layout); + if (layout) + llapi_layout_free(layout); free(lil);