Non-rpc layout driver such as for objects and blocks implement their own I/O path and error handling logic. Therefore bypass NFS-based error handling for these layout drivers. [fix lseg ref-count bugs, and null de-refs] [Fall out from: non-rpc layout drivers] Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> [get rid of PNFS_USE_RPC_CODE] [get rid of __nfs4_write_done_cb] [revert useless change in nfs4_write_done_cb] Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Unified · Split
| @@ -310,6 +310,7 @@ extern int nfs_migrate_page(struct address_space *, · 309 unmodified lines | |||
| 310 | #endif | 310 | #endif |
| 311 | 311 | ||
| 312 | /* nfs4proc.c */ | 312 | /* nfs4proc.c */ |
| 313 | extern void __nfs4_read_done_cb(struct nfs_read_data *); | ||
| 313 | extern void nfs4_reset_read(struct rpc_task *task, struct nfs_read_data *data); | 314 | extern void nfs4_reset_read(struct rpc_task *task, struct nfs_read_data *data); |
| 314 | extern int nfs4_init_client(struct nfs_client *clp, | 315 | extern int nfs4_init_client(struct nfs_client *clp, |
| 315 | const struct rpc_timeout *timeparms, | 316 | const struct rpc_timeout *timeparms, |
| @@ -3175,6 +3175,11 @@ static int nfs4_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, · 3174 unmodified lines | |||
| 3175 | return err; | 3175 | return err; |
| 3176 | } | 3176 | } |
| 3177 | 3177 | ||
| 3178 | void __nfs4_read_done_cb(struct nfs_read_data *data) | ||
| 3179 | { | ||
| 3180 | nfs_invalidate_atime(data->inode); | ||
| 3181 | } | ||
| 3182 | |||
| 3178 | static int nfs4_read_done_cb(struct rpc_task *task, struct nfs_read_data *data) | 3183 | static int nfs4_read_done_cb(struct rpc_task *task, struct nfs_read_data *data) |
| 3179 | { | 3184 | { |
| 3180 | struct nfs_server *server = NFS_SERVER(data->inode); | 3185 | struct nfs_server *server = NFS_SERVER(data->inode); |
| @@ -3184,7 +3189,7 @@ static int nfs4_read_done_cb(struct rpc_task *task, struct nfs_read_data *data) · 3 unmodified lines | |||
| 3184 | return -EAGAIN; | 3189 | return -EAGAIN; |
| 3185 | } | 3190 | } |
| 3186 | 3191 | ||
| 3187 | nfs_invalidate_atime(data->inode); | 3192 | __nfs4_read_done_cb(data); |
| 3188 | if (task->tk_status > 0) | 3193 | if (task->tk_status > 0) |
| 3189 | renew_lease(server, data->timestamp); | 3194 | renew_lease(server, data->timestamp); |
| 3190 | return 0; | 3195 | return 0; |
| @@ -3198,7 +3203,8 @@ static int nfs4_read_done(struct rpc_task *task, struct nfs_read_data *data) · 7 unmodified lines | |||
| 3198 | if (!nfs4_sequence_done(task, &data->res.seq_res)) | 3203 | if (!nfs4_sequence_done(task, &data->res.seq_res)) |
| 3199 | return -EAGAIN; | 3204 | return -EAGAIN; |
| 3200 | 3205 | ||
| 3201 | return data->read_done_cb(task, data); | 3206 | return data->read_done_cb ? data->read_done_cb(task, data) : |
| 3207 | nfs4_read_done_cb(task, data); | ||
| 3202 | } | 3208 | } |
| 3203 | 3209 | ||
| 3204 | static void nfs4_proc_read_setup(struct nfs_read_data *data, struct rpc_message *msg) | 3210 | static void nfs4_proc_read_setup(struct nfs_read_data *data, struct rpc_message *msg) |
| @@ -3243,7 +3249,8 @@ static int nfs4_write_done(struct rpc_task *task, struct nfs_write_data *data) · 38 unmodified lines | |||
| 3243 | { | 3249 | { |
| 3244 | if (!nfs4_sequence_done(task, &data->res.seq_res)) | 3250 | if (!nfs4_sequence_done(task, &data->res.seq_res)) |
| 3245 | return -EAGAIN; | 3251 | return -EAGAIN; |
| 3246 | return data->write_done_cb(task, data); | 3252 | return data->write_done_cb ? data->write_done_cb(task, data) : |
| 3253 | nfs4_write_done_cb(task, data); | ||
| 3247 | } | 3254 | } |
| 3248 | 3255 | ||
| 3249 | /* Reset the the nfs_write_data to send the write to the MDS. */ | 3256 | /* Reset the the nfs_write_data to send the write to the MDS. */ |
| @@ -243,7 +243,7 @@ put_lseg_common(struct pnfs_layout_segment *lseg) · 242 unmodified lines | |||
| 243 | { | 243 | { |
| 244 | struct inode *inode = lseg->pls_layout->plh_inode; | 244 | struct inode *inode = lseg->pls_layout->plh_inode; |
| 245 | 245 | ||
| 246 | BUG_ON(test_bit(NFS_LSEG_VALID, &lseg->pls_flags)); | 246 | WARN_ON(test_bit(NFS_LSEG_VALID, &lseg->pls_flags)); |
| 247 | list_del_init(&lseg->pls_list); | 247 | list_del_init(&lseg->pls_list); |
| 248 | if (list_empty(&lseg->pls_layout->plh_segs)) { | 248 | if (list_empty(&lseg->pls_layout->plh_segs)) { |
| 249 | set_bit(NFS_LAYOUT_DESTROYED, &lseg->pls_layout->plh_flags); | 249 | set_bit(NFS_LAYOUT_DESTROYED, &lseg->pls_layout->plh_flags); |
| @@ -1054,6 +1054,29 @@ pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode) · 804 unmodified lines | |||
| 1054 | pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test : NULL; | 1054 | pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test : NULL; |
| 1055 | } | 1055 | } |
| 1056 | 1056 | ||
| 1057 | /* | ||
| 1058 | * Called by non rpc-based layout drivers | ||
| 1059 | */ | ||
| 1060 | int | ||
| 1061 | pnfs_ld_write_done(struct nfs_write_data *data) | ||
| 1062 | { | ||
| 1063 | int status; | ||
| 1064 | |||
| 1065 | if (!data->pnfs_error) { | ||
| 1066 | pnfs_set_layoutcommit(data); | ||
| 1067 | data->mds_ops->rpc_call_done(&data->task, data); | ||
| 1068 | data->mds_ops->rpc_release(data); | ||
| 1069 | return 0; | ||
| 1070 | } | ||
| 1071 | |||
| 1072 | dprintk("%s: pnfs_error=%d, retry via MDS\n", __func__, | ||
| 1073 | data->pnfs_error); | ||
| 1074 | status = nfs_initiate_write(data, NFS_CLIENT(data->inode), | ||
| 1075 | data->mds_ops, NFS_FILE_SYNC); | ||
| 1076 | return status ? : -EAGAIN; | ||
| 1077 | } | ||
| 1078 | EXPORT_SYMBOL_GPL(pnfs_ld_write_done); | ||
| 1079 | |||
| 1057 | enum pnfs_try_status | 1080 | enum pnfs_try_status |
| 1058 | pnfs_try_to_write_data(struct nfs_write_data *wdata, | 1081 | pnfs_try_to_write_data(struct nfs_write_data *wdata, |
| 1059 | const struct rpc_call_ops *call_ops, int how) | 1082 | const struct rpc_call_ops *call_ops, int how) |
| @@ -1078,6 +1101,29 @@ pnfs_try_to_write_data(struct nfs_write_data *wdata, · 18 unmodified lines | |||
| 1078 | return trypnfs; | 1101 | return trypnfs; |
| 1079 | } | 1102 | } |
| 1080 | 1103 | ||
| 1104 | /* | ||
| 1105 | * Called by non rpc-based layout drivers | ||
| 1106 | */ | ||
| 1107 | int | ||
| 1108 | pnfs_ld_read_done(struct nfs_read_data *data) | ||
| 1109 | { | ||
| 1110 | int status; | ||
| 1111 | |||
| 1112 | if (!data->pnfs_error) { | ||
| 1113 | __nfs4_read_done_cb(data); | ||
| 1114 | data->mds_ops->rpc_call_done(&data->task, data); | ||
| 1115 | data->mds_ops->rpc_release(data); | ||
| 1116 | return 0; | ||
| 1117 | } | ||
| 1118 | |||
| 1119 | dprintk("%s: pnfs_error=%d, retry via MDS\n", __func__, | ||
| 1120 | data->pnfs_error); | ||
| 1121 | status = nfs_initiate_read(data, NFS_CLIENT(data->inode), | ||
| 1122 | data->mds_ops); | ||
| 1123 | return status ? : -EAGAIN; | ||
| 1124 | } | ||
| 1125 | EXPORT_SYMBOL_GPL(pnfs_ld_read_done); | ||
| 1126 | |||
| 1081 | /* | 1127 | /* |
| 1082 | * Call the appropriate parallel I/O subsystem read function. | 1128 | * Call the appropriate parallel I/O subsystem read function. |
| 1083 | */ | 1129 | */ |
| @@ -165,6 +165,8 @@ void pnfs_roc_set_barrier(struct inode *ino, u32 barrier); · 164 unmodified lines | |||
| 165 | bool pnfs_roc_drain(struct inode *ino, u32 *barrier); | 165 | bool pnfs_roc_drain(struct inode *ino, u32 *barrier); |
| 166 | void pnfs_set_layoutcommit(struct nfs_write_data *wdata); | 166 | void pnfs_set_layoutcommit(struct nfs_write_data *wdata); |
| 167 | int pnfs_layoutcommit_inode(struct inode *inode, bool sync); | 167 | int pnfs_layoutcommit_inode(struct inode *inode, bool sync); |
| 168 | int pnfs_ld_write_done(struct nfs_write_data *); | ||
| 169 | int pnfs_ld_read_done(struct nfs_read_data *); | ||
| 168 | 170 | ||
| 169 | /* pnfs_dev.c */ | 171 | /* pnfs_dev.c */ |
| 170 | struct nfs4_deviceid_node { | 172 | struct nfs4_deviceid_node { |
| @@ -1087,6 +1087,7 @@ struct nfs_read_data { · 1086 unmodified lines | |||
| 1087 | const struct rpc_call_ops *mds_ops; | 1087 | const struct rpc_call_ops *mds_ops; |
| 1088 | int (*read_done_cb) (struct rpc_task *task, struct nfs_read_data *data); | 1088 | int (*read_done_cb) (struct rpc_task *task, struct nfs_read_data *data); |
| 1089 | __u64 mds_offset; | 1089 | __u64 mds_offset; |
| 1090 | int pnfs_error; | ||
| 1090 | struct page *page_array[NFS_PAGEVEC_SIZE]; | 1091 | struct page *page_array[NFS_PAGEVEC_SIZE]; |
| 1091 | }; | 1092 | }; |
| 1092 | 1093 | ||
| @@ -1112,6 +1113,7 @@ struct nfs_write_data { · 19 unmodified lines | |||
| 1112 | unsigned long timestamp; /* For lease renewal */ | 1113 | unsigned long timestamp; /* For lease renewal */ |
| 1113 | #endif | 1114 | #endif |
| 1114 | __u64 mds_offset; /* Filelayout dense stripe */ | 1115 | __u64 mds_offset; /* Filelayout dense stripe */ |
| 1116 | int pnfs_error; | ||
| 1115 | struct page *page_array[NFS_PAGEVEC_SIZE]; | 1117 | struct page *page_array[NFS_PAGEVEC_SIZE]; |
| 1116 | }; | 1118 | }; |
| 1117 | 1119 | ||