Whamcloud - gitweb
EX-9372 lpurge: rid of dup layout get
authorBobi Jam <bobijam@whamcloud.com>
Fri, 22 Mar 2024 07:49:21 +0000 (15:49 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 23 Mar 2024 20:30:03 +0000 (20:30 +0000)
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 <bobijam@whamcloud.com>
Change-Id: If4e6e3a9c46ab782f08e5bc5b3710339af051719
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54527
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Alexandre Ioffe <aioffe@ddn.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alexandre Ioffe <aioffe@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lipe/src/lpurge.c

index 240a43f..2b72e1e 100644 (file)
@@ -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);