diff options
author | Andy Adamson <andros@netapp.com> | 2012-04-27 17:53:42 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-05-19 17:54:18 -0400 |
commit | 554d458d79fa34acc73bc5128ba7bbf6b3007dfd (patch) | |
tree | e3b433888cfb494e234bb0a068563591f83cdcc2 /fs/nfs | |
parent | e73e6c9e85ed91187c1d21cb9238e86a116bf3db (diff) |
NFSv4.1: cleanup filelayout invalid deviceid handling
Move the invalid deviceid test into nfs4_fl_prepare_ds, called by the
filelayout read, write, and commit routines. NFS4_DEVICE_ID_NEG_ENTRY
is no longer needed.
Remove redundant printk's - filelayout_mark_devid_invalid prints a KERN_WARNING.
An invalid device prevents pNFS io.
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/nfs4filelayout.c | 10 | ||||
-rw-r--r-- | fs/nfs/nfs4filelayout.h | 21 | ||||
-rw-r--r-- | fs/nfs/nfs4filelayoutdev.c | 37 |
3 files changed, 28 insertions, 40 deletions
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c index 80a63f6d9e14..eebec9a7641a 100644 --- a/fs/nfs/nfs4filelayout.c +++ b/fs/nfs/nfs4filelayout.c | |||
@@ -389,9 +389,6 @@ filelayout_read_pagelist(struct nfs_read_data *data) | |||
389 | __func__, hdr->inode->i_ino, | 389 | __func__, hdr->inode->i_ino, |
390 | data->args.pgbase, (size_t)data->args.count, offset); | 390 | data->args.pgbase, (size_t)data->args.count, offset); |
391 | 391 | ||
392 | if (test_bit(NFS_DEVICEID_INVALID, &FILELAYOUT_DEVID_NODE(lseg)->flags)) | ||
393 | return PNFS_NOT_ATTEMPTED; | ||
394 | |||
395 | /* Retrieve the correct rpc_client for the byte range */ | 392 | /* Retrieve the correct rpc_client for the byte range */ |
396 | j = nfs4_fl_calc_j_index(lseg, offset); | 393 | j = nfs4_fl_calc_j_index(lseg, offset); |
397 | idx = nfs4_fl_calc_ds_index(lseg, j); | 394 | idx = nfs4_fl_calc_ds_index(lseg, j); |
@@ -432,16 +429,11 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync) | |||
432 | struct nfs_fh *fh; | 429 | struct nfs_fh *fh; |
433 | int status; | 430 | int status; |
434 | 431 | ||
435 | if (test_bit(NFS_DEVICEID_INVALID, &FILELAYOUT_DEVID_NODE(lseg)->flags)) | ||
436 | return PNFS_NOT_ATTEMPTED; | ||
437 | |||
438 | /* Retrieve the correct rpc_client for the byte range */ | 432 | /* Retrieve the correct rpc_client for the byte range */ |
439 | j = nfs4_fl_calc_j_index(lseg, offset); | 433 | j = nfs4_fl_calc_j_index(lseg, offset); |
440 | idx = nfs4_fl_calc_ds_index(lseg, j); | 434 | idx = nfs4_fl_calc_ds_index(lseg, j); |
441 | ds = nfs4_fl_prepare_ds(lseg, idx); | 435 | ds = nfs4_fl_prepare_ds(lseg, idx); |
442 | if (!ds) { | 436 | if (!ds) { |
443 | printk(KERN_ERR "NFS: %s: prepare_ds failed, use MDS\n", | ||
444 | __func__); | ||
445 | set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags); | 437 | set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags); |
446 | set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags); | 438 | set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags); |
447 | return PNFS_NOT_ATTEMPTED; | 439 | return PNFS_NOT_ATTEMPTED; |
@@ -977,8 +969,6 @@ static int filelayout_initiate_commit(struct nfs_commit_data *data, int how) | |||
977 | idx = calc_ds_index_from_commit(lseg, data->ds_commit_index); | 969 | idx = calc_ds_index_from_commit(lseg, data->ds_commit_index); |
978 | ds = nfs4_fl_prepare_ds(lseg, idx); | 970 | ds = nfs4_fl_prepare_ds(lseg, idx); |
979 | if (!ds) { | 971 | if (!ds) { |
980 | printk(KERN_ERR "NFS: %s: prepare_ds failed, use MDS\n", | ||
981 | __func__); | ||
982 | set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags); | 972 | set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags); |
983 | set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags); | 973 | set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags); |
984 | prepare_to_resend_writes(data); | 974 | prepare_to_resend_writes(data); |
diff --git a/fs/nfs/nfs4filelayout.h b/fs/nfs/nfs4filelayout.h index 96b89bbddf4f..2f6330c4ee3e 100644 --- a/fs/nfs/nfs4filelayout.h +++ b/fs/nfs/nfs4filelayout.h | |||
@@ -62,12 +62,8 @@ struct nfs4_pnfs_ds { | |||
62 | atomic_t ds_count; | 62 | atomic_t ds_count; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | /* nfs4_file_layout_dsaddr flags */ | ||
66 | #define NFS4_DEVICE_ID_NEG_ENTRY 0x00000001 | ||
67 | |||
68 | struct nfs4_file_layout_dsaddr { | 65 | struct nfs4_file_layout_dsaddr { |
69 | struct nfs4_deviceid_node id_node; | 66 | struct nfs4_deviceid_node id_node; |
70 | unsigned long flags; | ||
71 | u32 stripe_count; | 67 | u32 stripe_count; |
72 | u8 *stripe_indices; | 68 | u8 *stripe_indices; |
73 | u32 ds_num; | 69 | u32 ds_num; |
@@ -111,6 +107,23 @@ FILELAYOUT_DEVID_NODE(struct pnfs_layout_segment *lseg) | |||
111 | return &FILELAYOUT_LSEG(lseg)->dsaddr->id_node; | 107 | return &FILELAYOUT_LSEG(lseg)->dsaddr->id_node; |
112 | } | 108 | } |
113 | 109 | ||
110 | static inline void | ||
111 | filelayout_mark_devid_invalid(struct nfs4_deviceid_node *node) | ||
112 | { | ||
113 | u32 *p = (u32 *)&node->deviceid; | ||
114 | |||
115 | printk(KERN_WARNING "NFS: Deviceid [%x%x%x%x] marked out of use.\n", | ||
116 | p[0], p[1], p[2], p[3]); | ||
117 | |||
118 | set_bit(NFS_DEVICEID_INVALID, &node->flags); | ||
119 | } | ||
120 | |||
121 | static inline bool | ||
122 | filelayout_test_devid_invalid(struct nfs4_deviceid_node *node) | ||
123 | { | ||
124 | return test_bit(NFS_DEVICEID_INVALID, &node->flags); | ||
125 | } | ||
126 | |||
114 | extern struct nfs_fh * | 127 | extern struct nfs_fh * |
115 | nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, u32 j); | 128 | nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, u32 j); |
116 | 129 | ||
diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c index c9cff9adb2d3..7e0be3e331d7 100644 --- a/fs/nfs/nfs4filelayoutdev.c +++ b/fs/nfs/nfs4filelayoutdev.c | |||
@@ -791,48 +791,33 @@ nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, u32 j) | |||
791 | return flseg->fh_array[i]; | 791 | return flseg->fh_array[i]; |
792 | } | 792 | } |
793 | 793 | ||
794 | static void | ||
795 | filelayout_mark_devid_negative(struct nfs4_file_layout_dsaddr *dsaddr, | ||
796 | int err, const char *ds_remotestr) | ||
797 | { | ||
798 | u32 *p = (u32 *)&dsaddr->id_node.deviceid; | ||
799 | |||
800 | printk(KERN_ERR "NFS: data server %s connection error %d." | ||
801 | " Deviceid [%x%x%x%x] marked out of use.\n", | ||
802 | ds_remotestr, err, p[0], p[1], p[2], p[3]); | ||
803 | |||
804 | spin_lock(&nfs4_ds_cache_lock); | ||
805 | dsaddr->flags |= NFS4_DEVICE_ID_NEG_ENTRY; | ||
806 | spin_unlock(&nfs4_ds_cache_lock); | ||
807 | } | ||
808 | |||
809 | struct nfs4_pnfs_ds * | 794 | struct nfs4_pnfs_ds * |
810 | nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx) | 795 | nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx) |
811 | { | 796 | { |
812 | struct nfs4_file_layout_dsaddr *dsaddr = FILELAYOUT_LSEG(lseg)->dsaddr; | 797 | struct nfs4_file_layout_dsaddr *dsaddr = FILELAYOUT_LSEG(lseg)->dsaddr; |
813 | struct nfs4_pnfs_ds *ds = dsaddr->ds_list[ds_idx]; | 798 | struct nfs4_pnfs_ds *ds = dsaddr->ds_list[ds_idx]; |
799 | struct nfs4_deviceid_node *devid = FILELAYOUT_DEVID_NODE(lseg); | ||
800 | |||
801 | if (filelayout_test_devid_invalid(devid)) | ||
802 | return NULL; | ||
814 | 803 | ||
815 | if (ds == NULL) { | 804 | if (ds == NULL) { |
816 | printk(KERN_ERR "NFS: %s: No data server for offset index %d\n", | 805 | printk(KERN_ERR "NFS: %s: No data server for offset index %d\n", |
817 | __func__, ds_idx); | 806 | __func__, ds_idx); |
818 | return NULL; | 807 | goto mark_dev_invalid; |
819 | } | 808 | } |
820 | 809 | ||
821 | if (!ds->ds_clp) { | 810 | if (!ds->ds_clp) { |
822 | struct nfs_server *s = NFS_SERVER(lseg->pls_layout->plh_inode); | 811 | struct nfs_server *s = NFS_SERVER(lseg->pls_layout->plh_inode); |
823 | int err; | 812 | int err; |
824 | 813 | ||
825 | if (dsaddr->flags & NFS4_DEVICE_ID_NEG_ENTRY) { | ||
826 | /* Already tried to connect, don't try again */ | ||
827 | dprintk("%s Deviceid marked out of use\n", __func__); | ||
828 | return NULL; | ||
829 | } | ||
830 | err = nfs4_ds_connect(s, ds); | 814 | err = nfs4_ds_connect(s, ds); |
831 | if (err) { | 815 | if (err) |
832 | filelayout_mark_devid_negative(dsaddr, err, | 816 | goto mark_dev_invalid; |
833 | ds->ds_remotestr); | ||
834 | return NULL; | ||
835 | } | ||
836 | } | 817 | } |
837 | return ds; | 818 | return ds; |
819 | |||
820 | mark_dev_invalid: | ||
821 | filelayout_mark_devid_invalid(devid); | ||
822 | return NULL; | ||
838 | } | 823 | } |