aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorPeng Tao <bergwolf@gmail.com>2011-09-22 21:50:12 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-10-18 12:08:13 -0400
commit1b0ae068779874f54b55aac3a2a992bcf3f2c3c4 (patch)
tree2cfc6f406312ca02704fedb9675a02a5ec2993bf /fs/nfs
parent760383f1ee4d14b0e0bdf0cddee648d9b8633429 (diff)
pnfs: make _set_lo_fail generic
file layout and block layout both use it to set mark layout io failure bit. So make it generic. Signed-off-by: Peng Tao <peng_tao@emc.com> Signed-off-by: Jim Rees <rees@umich.edu> Cc: stable@kernel.org [3.0] Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/blocklayout/blocklayout.c17
-rw-r--r--fs/nfs/nfs4filelayout.c19
-rw-r--r--fs/nfs/pnfs.c12
-rw-r--r--fs/nfs/pnfs.h1
4 files changed, 19 insertions, 30 deletions
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index dee6cae80fea..2167ba2afdbb 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -176,17 +176,6 @@ retry:
176 return bio; 176 return bio;
177} 177}
178 178
179static void bl_set_lo_fail(struct pnfs_layout_segment *lseg)
180{
181 if (lseg->pls_range.iomode == IOMODE_RW) {
182 dprintk("%s Setting layout IOMODE_RW fail bit\n", __func__);
183 set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags);
184 } else {
185 dprintk("%s Setting layout IOMODE_READ fail bit\n", __func__);
186 set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags);
187 }
188}
189
190/* This is basically copied from mpage_end_io_read */ 179/* This is basically copied from mpage_end_io_read */
191static void bl_end_io_read(struct bio *bio, int err) 180static void bl_end_io_read(struct bio *bio, int err)
192{ 181{
@@ -206,7 +195,7 @@ static void bl_end_io_read(struct bio *bio, int err)
206 if (!uptodate) { 195 if (!uptodate) {
207 if (!rdata->pnfs_error) 196 if (!rdata->pnfs_error)
208 rdata->pnfs_error = -EIO; 197 rdata->pnfs_error = -EIO;
209 bl_set_lo_fail(rdata->lseg); 198 pnfs_set_lo_fail(rdata->lseg);
210 } 199 }
211 bio_put(bio); 200 bio_put(bio);
212 put_parallel(par); 201 put_parallel(par);
@@ -370,7 +359,7 @@ static void bl_end_io_write_zero(struct bio *bio, int err)
370 if (!uptodate) { 359 if (!uptodate) {
371 if (!wdata->pnfs_error) 360 if (!wdata->pnfs_error)
372 wdata->pnfs_error = -EIO; 361 wdata->pnfs_error = -EIO;
373 bl_set_lo_fail(wdata->lseg); 362 pnfs_set_lo_fail(wdata->lseg);
374 } 363 }
375 bio_put(bio); 364 bio_put(bio);
376 put_parallel(par); 365 put_parallel(par);
@@ -386,7 +375,7 @@ static void bl_end_io_write(struct bio *bio, int err)
386 if (!uptodate) { 375 if (!uptodate) {
387 if (!wdata->pnfs_error) 376 if (!wdata->pnfs_error)
388 wdata->pnfs_error = -EIO; 377 wdata->pnfs_error = -EIO;
389 bl_set_lo_fail(wdata->lseg); 378 pnfs_set_lo_fail(wdata->lseg);
390 } 379 }
391 bio_put(bio); 380 bio_put(bio);
392 put_parallel(par); 381 put_parallel(par);
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index e8915d4840ad..4c78c62639e6 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -77,19 +77,6 @@ filelayout_get_dserver_offset(struct pnfs_layout_segment *lseg, loff_t offset)
77 BUG(); 77 BUG();
78} 78}
79 79
80/* For data server errors we don't recover from */
81static void
82filelayout_set_lo_fail(struct pnfs_layout_segment *lseg)
83{
84 if (lseg->pls_range.iomode == IOMODE_RW) {
85 dprintk("%s Setting layout IOMODE_RW fail bit\n", __func__);
86 set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags);
87 } else {
88 dprintk("%s Setting layout IOMODE_READ fail bit\n", __func__);
89 set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags);
90 }
91}
92
93static int filelayout_async_handle_error(struct rpc_task *task, 80static int filelayout_async_handle_error(struct rpc_task *task,
94 struct nfs4_state *state, 81 struct nfs4_state *state,
95 struct nfs_client *clp, 82 struct nfs_client *clp,
@@ -145,7 +132,7 @@ static int filelayout_read_done_cb(struct rpc_task *task,
145 dprintk("%s calling restart ds_clp %p ds_clp->cl_session %p\n", 132 dprintk("%s calling restart ds_clp %p ds_clp->cl_session %p\n",
146 __func__, data->ds_clp, data->ds_clp->cl_session); 133 __func__, data->ds_clp, data->ds_clp->cl_session);
147 if (reset) { 134 if (reset) {
148 filelayout_set_lo_fail(data->lseg); 135 pnfs_set_lo_fail(data->lseg);
149 nfs4_reset_read(task, data); 136 nfs4_reset_read(task, data);
150 clp = NFS_SERVER(data->inode)->nfs_client; 137 clp = NFS_SERVER(data->inode)->nfs_client;
151 } 138 }
@@ -221,7 +208,7 @@ static int filelayout_write_done_cb(struct rpc_task *task,
221 dprintk("%s calling restart ds_clp %p ds_clp->cl_session %p\n", 208 dprintk("%s calling restart ds_clp %p ds_clp->cl_session %p\n",
222 __func__, data->ds_clp, data->ds_clp->cl_session); 209 __func__, data->ds_clp, data->ds_clp->cl_session);
223 if (reset) { 210 if (reset) {
224 filelayout_set_lo_fail(data->lseg); 211 pnfs_set_lo_fail(data->lseg);
225 nfs4_reset_write(task, data); 212 nfs4_reset_write(task, data);
226 clp = NFS_SERVER(data->inode)->nfs_client; 213 clp = NFS_SERVER(data->inode)->nfs_client;
227 } else 214 } else
@@ -256,7 +243,7 @@ static int filelayout_commit_done_cb(struct rpc_task *task,
256 __func__, data->ds_clp, data->ds_clp->cl_session); 243 __func__, data->ds_clp, data->ds_clp->cl_session);
257 if (reset) { 244 if (reset) {
258 prepare_to_resend_writes(data); 245 prepare_to_resend_writes(data);
259 filelayout_set_lo_fail(data->lseg); 246 pnfs_set_lo_fail(data->lseg);
260 } else 247 } else
261 nfs_restart_rpc(task, data->ds_clp); 248 nfs_restart_rpc(task, data->ds_clp);
262 return -EAGAIN; 249 return -EAGAIN;
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index e550e8836c37..6b19fffa812a 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1381,6 +1381,18 @@ static void pnfs_list_write_lseg(struct inode *inode, struct list_head *listp)
1381 } 1381 }
1382} 1382}
1383 1383
1384void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg)
1385{
1386 if (lseg->pls_range.iomode == IOMODE_RW) {
1387 dprintk("%s Setting layout IOMODE_RW fail bit\n", __func__);
1388 set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags);
1389 } else {
1390 dprintk("%s Setting layout IOMODE_READ fail bit\n", __func__);
1391 set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags);
1392 }
1393}
1394EXPORT_SYMBOL_GPL(pnfs_set_lo_fail);
1395
1384void 1396void
1385pnfs_set_layoutcommit(struct nfs_write_data *wdata) 1397pnfs_set_layoutcommit(struct nfs_write_data *wdata)
1386{ 1398{
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 01cbfd54f3cb..94e760eb543a 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -178,6 +178,7 @@ int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc);
178void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *, struct nfs_page *); 178void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *, struct nfs_page *);
179int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc); 179int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc);
180bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req); 180bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req);
181void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg);
181int pnfs_layout_process(struct nfs4_layoutget *lgp); 182int pnfs_layout_process(struct nfs4_layoutget *lgp);
182void pnfs_free_lseg_list(struct list_head *tmp_list); 183void pnfs_free_lseg_list(struct list_head *tmp_list);
183void pnfs_destroy_layout(struct nfs_inode *); 184void pnfs_destroy_layout(struct nfs_inode *);