Commit 1b0ae068 authored by Peng Tao's avatar Peng Tao Committed by Trond Myklebust

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: default avatarPeng Tao <peng_tao@emc.com>
Signed-off-by: default avatarJim Rees <rees@umich.edu>
Cc: stable@kernel.org [3.0]
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 760383f1
...@@ -176,17 +176,6 @@ static struct bio *bl_add_page_to_bio(struct bio *bio, int npg, int rw, ...@@ -176,17 +176,6 @@ static struct bio *bl_add_page_to_bio(struct bio *bio, int npg, int rw,
return bio; return bio;
} }
static void bl_set_lo_fail(struct pnfs_layout_segment *lseg)
{
if (lseg->pls_range.iomode == IOMODE_RW) {
dprintk("%s Setting layout IOMODE_RW fail bit\n", __func__);
set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags);
} else {
dprintk("%s Setting layout IOMODE_READ fail bit\n", __func__);
set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags);
}
}
/* This is basically copied from mpage_end_io_read */ /* This is basically copied from mpage_end_io_read */
static void bl_end_io_read(struct bio *bio, int err) static void bl_end_io_read(struct bio *bio, int err)
{ {
...@@ -206,7 +195,7 @@ static void bl_end_io_read(struct bio *bio, int err) ...@@ -206,7 +195,7 @@ static void bl_end_io_read(struct bio *bio, int err)
if (!uptodate) { if (!uptodate) {
if (!rdata->pnfs_error) if (!rdata->pnfs_error)
rdata->pnfs_error = -EIO; rdata->pnfs_error = -EIO;
bl_set_lo_fail(rdata->lseg); pnfs_set_lo_fail(rdata->lseg);
} }
bio_put(bio); bio_put(bio);
put_parallel(par); put_parallel(par);
...@@ -370,7 +359,7 @@ static void bl_end_io_write_zero(struct bio *bio, int err) ...@@ -370,7 +359,7 @@ static void bl_end_io_write_zero(struct bio *bio, int err)
if (!uptodate) { if (!uptodate) {
if (!wdata->pnfs_error) if (!wdata->pnfs_error)
wdata->pnfs_error = -EIO; wdata->pnfs_error = -EIO;
bl_set_lo_fail(wdata->lseg); pnfs_set_lo_fail(wdata->lseg);
} }
bio_put(bio); bio_put(bio);
put_parallel(par); put_parallel(par);
...@@ -386,7 +375,7 @@ static void bl_end_io_write(struct bio *bio, int err) ...@@ -386,7 +375,7 @@ static void bl_end_io_write(struct bio *bio, int err)
if (!uptodate) { if (!uptodate) {
if (!wdata->pnfs_error) if (!wdata->pnfs_error)
wdata->pnfs_error = -EIO; wdata->pnfs_error = -EIO;
bl_set_lo_fail(wdata->lseg); pnfs_set_lo_fail(wdata->lseg);
} }
bio_put(bio); bio_put(bio);
put_parallel(par); put_parallel(par);
......
...@@ -77,19 +77,6 @@ filelayout_get_dserver_offset(struct pnfs_layout_segment *lseg, loff_t offset) ...@@ -77,19 +77,6 @@ filelayout_get_dserver_offset(struct pnfs_layout_segment *lseg, loff_t offset)
BUG(); BUG();
} }
/* For data server errors we don't recover from */
static void
filelayout_set_lo_fail(struct pnfs_layout_segment *lseg)
{
if (lseg->pls_range.iomode == IOMODE_RW) {
dprintk("%s Setting layout IOMODE_RW fail bit\n", __func__);
set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags);
} else {
dprintk("%s Setting layout IOMODE_READ fail bit\n", __func__);
set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags);
}
}
static int filelayout_async_handle_error(struct rpc_task *task, static int filelayout_async_handle_error(struct rpc_task *task,
struct nfs4_state *state, struct nfs4_state *state,
struct nfs_client *clp, struct nfs_client *clp,
...@@ -145,7 +132,7 @@ static int filelayout_read_done_cb(struct rpc_task *task, ...@@ -145,7 +132,7 @@ static int filelayout_read_done_cb(struct rpc_task *task,
dprintk("%s calling restart ds_clp %p ds_clp->cl_session %p\n", dprintk("%s calling restart ds_clp %p ds_clp->cl_session %p\n",
__func__, data->ds_clp, data->ds_clp->cl_session); __func__, data->ds_clp, data->ds_clp->cl_session);
if (reset) { if (reset) {
filelayout_set_lo_fail(data->lseg); pnfs_set_lo_fail(data->lseg);
nfs4_reset_read(task, data); nfs4_reset_read(task, data);
clp = NFS_SERVER(data->inode)->nfs_client; clp = NFS_SERVER(data->inode)->nfs_client;
} }
...@@ -221,7 +208,7 @@ static int filelayout_write_done_cb(struct rpc_task *task, ...@@ -221,7 +208,7 @@ static int filelayout_write_done_cb(struct rpc_task *task,
dprintk("%s calling restart ds_clp %p ds_clp->cl_session %p\n", dprintk("%s calling restart ds_clp %p ds_clp->cl_session %p\n",
__func__, data->ds_clp, data->ds_clp->cl_session); __func__, data->ds_clp, data->ds_clp->cl_session);
if (reset) { if (reset) {
filelayout_set_lo_fail(data->lseg); pnfs_set_lo_fail(data->lseg);
nfs4_reset_write(task, data); nfs4_reset_write(task, data);
clp = NFS_SERVER(data->inode)->nfs_client; clp = NFS_SERVER(data->inode)->nfs_client;
} else } else
...@@ -256,7 +243,7 @@ static int filelayout_commit_done_cb(struct rpc_task *task, ...@@ -256,7 +243,7 @@ static int filelayout_commit_done_cb(struct rpc_task *task,
__func__, data->ds_clp, data->ds_clp->cl_session); __func__, data->ds_clp, data->ds_clp->cl_session);
if (reset) { if (reset) {
prepare_to_resend_writes(data); prepare_to_resend_writes(data);
filelayout_set_lo_fail(data->lseg); pnfs_set_lo_fail(data->lseg);
} else } else
nfs_restart_rpc(task, data->ds_clp); nfs_restart_rpc(task, data->ds_clp);
return -EAGAIN; return -EAGAIN;
......
...@@ -1381,6 +1381,18 @@ static void pnfs_list_write_lseg(struct inode *inode, struct list_head *listp) ...@@ -1381,6 +1381,18 @@ static void pnfs_list_write_lseg(struct inode *inode, struct list_head *listp)
} }
} }
void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg)
{
if (lseg->pls_range.iomode == IOMODE_RW) {
dprintk("%s Setting layout IOMODE_RW fail bit\n", __func__);
set_bit(lo_fail_bit(IOMODE_RW), &lseg->pls_layout->plh_flags);
} else {
dprintk("%s Setting layout IOMODE_READ fail bit\n", __func__);
set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags);
}
}
EXPORT_SYMBOL_GPL(pnfs_set_lo_fail);
void void
pnfs_set_layoutcommit(struct nfs_write_data *wdata) pnfs_set_layoutcommit(struct nfs_write_data *wdata)
{ {
......
...@@ -178,6 +178,7 @@ int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc); ...@@ -178,6 +178,7 @@ int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc);
void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *, struct nfs_page *); void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *, struct nfs_page *);
int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc); int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc);
bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req); bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req);
void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg);
int pnfs_layout_process(struct nfs4_layoutget *lgp); int pnfs_layout_process(struct nfs4_layoutget *lgp);
void pnfs_free_lseg_list(struct list_head *tmp_list); void pnfs_free_lseg_list(struct list_head *tmp_list);
void pnfs_destroy_layout(struct nfs_inode *); void pnfs_destroy_layout(struct nfs_inode *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment