Skip to content

Commit 0b9018b

Browse files
olgakorn1Olga Kornievskaia
authored andcommitted
NFS: skip recovery of copy open on dest server
Mark the open created for the source file on the destination server. Then if this open is going thru a recovery, then fail the recovery as we don't need to be recoving a "fake" open. We need to fail the ongoing READs and vfs_copy_file_range(). Signed-off-by: Olga Kornievskaia <[email protected]>
1 parent ec4b092 commit 0b9018b

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

fs/nfs/nfs4_fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ enum {
168168
NFS_STATE_CHANGE_WAIT, /* A state changing operation is outstanding */
169169
#ifdef CONFIG_NFS_V4_2
170170
NFS_CLNT_DST_SSC_COPY_STATE, /* dst server open state on client*/
171+
NFS_SRV_SSC_COPY_STATE, /* ssc state on the dst server */
171172
#endif /* CONFIG_NFS_V4_2 */
172173
};
173174

fs/nfs/nfs4file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh,
352352
if (ctx->state == NULL)
353353
goto out_stateowner;
354354

355+
set_bit(NFS_SRV_SSC_COPY_STATE, &ctx->state->flags);
355356
set_bit(NFS_OPEN_STATE, &ctx->state->flags);
356357
memcpy(&ctx->state->open_stateid.other, &stateid->other,
357358
NFS4_STATEID_OTHER_SIZE);

fs/nfs/nfs4state.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,9 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
16091609
struct nfs4_state *state;
16101610
unsigned int loop = 0;
16111611
int status = 0;
1612+
#ifdef CONFIG_NFS_V4_2
1613+
bool found_ssc_copy_state = false;
1614+
#endif /* CONFIG_NFS_V4_2 */
16121615

16131616
/* Note: we rely on the sp->so_states list being ordered
16141617
* so that we always reclaim open(O_RDWR) and/or open(O_WRITE)
@@ -1628,6 +1631,13 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
16281631
continue;
16291632
if (state->state == 0)
16301633
continue;
1634+
#ifdef CONFIG_NFS_V4_2
1635+
if (test_bit(NFS_SRV_SSC_COPY_STATE, &state->flags)) {
1636+
nfs4_state_mark_recovery_failed(state, -EIO);
1637+
found_ssc_copy_state = true;
1638+
continue;
1639+
}
1640+
#endif /* CONFIG_NFS_V4_2 */
16311641
refcount_inc(&state->count);
16321642
spin_unlock(&sp->so_lock);
16331643
status = __nfs4_reclaim_open_state(sp, state, ops);
@@ -1682,6 +1692,10 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
16821692
}
16831693
raw_write_seqcount_end(&sp->so_reclaim_seqcount);
16841694
spin_unlock(&sp->so_lock);
1695+
#ifdef CONFIG_NFS_V4_2
1696+
if (found_ssc_copy_state)
1697+
return -EIO;
1698+
#endif /* CONFIG_NFS_V4_2 */
16851699
return 0;
16861700
out_err:
16871701
nfs4_put_open_state(state);

0 commit comments

Comments
 (0)