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",
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;
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;
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);