Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 374817
b: refs/heads/master
c: c23266d
h: refs/heads/master
i:
  374815: 48f155b
v: v3
  • Loading branch information
Andy Adamson authored and Trond Myklebust committed May 8, 2013
1 parent 62e1281 commit ccc7d47
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d497ab975141666e674e7bd8729e00095ec23c9d
refs/heads/master: c23266d532b4de796a346f57a66587c5db17d27e
2 changes: 2 additions & 0 deletions trunk/fs/nfs/nfs4filelayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ struct nfs4_pnfs_ds {
struct list_head ds_addrs;
struct nfs_client *ds_clp;
atomic_t ds_count;
unsigned long ds_state;
#define NFS4DS_CONNECTING 0 /* ds is establishing connection */
};

struct nfs4_file_layout_dsaddr {
Expand Down
26 changes: 24 additions & 2 deletions trunk/fs/nfs/nfs4filelayoutdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,22 @@ nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, u32 j)
return flseg->fh_array[i];
}

static void nfs4_wait_ds_connect(struct nfs4_pnfs_ds *ds)
{
might_sleep();
wait_on_bit(&ds->ds_state, NFS4DS_CONNECTING,
nfs_wait_bit_killable, TASK_KILLABLE);
}

static void nfs4_clear_ds_conn_bit(struct nfs4_pnfs_ds *ds)
{
smp_mb__before_clear_bit();
clear_bit(NFS4DS_CONNECTING, &ds->ds_state);
smp_mb__after_clear_bit();
wake_up_bit(&ds->ds_state, NFS4DS_CONNECTING);
}


struct nfs4_pnfs_ds *
nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx)
{
Expand All @@ -791,16 +807,22 @@ nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx)
filelayout_mark_devid_invalid(devid);
return NULL;
}
if (ds->ds_clp)
return ds;

if (!ds->ds_clp) {
if (test_and_set_bit(NFS4DS_CONNECTING, &ds->ds_state) == 0) {
struct nfs_server *s = NFS_SERVER(lseg->pls_layout->plh_inode);
int err;

err = nfs4_ds_connect(s, ds);
if (err) {
nfs4_mark_deviceid_unavailable(devid);
return NULL;
ds = NULL;
}
nfs4_clear_ds_conn_bit(ds);
} else {
/* Either ds is connected, or ds is NULL */
nfs4_wait_ds_connect(ds);
}
return ds;
}
Expand Down

0 comments on commit ccc7d47

Please sign in to comment.