filelayout.c (de1414a654e66b81b5348dbc5259ecf2fb61655e) | filelayout.c (f54bcf2ecee982da47c2baf8bd87fd9ad9984651) |
---|---|
1/* 2 * Module for the pnfs nfs4 file layout driver. 3 * Defines all I/O and Policy interface operations, plus code 4 * to register itself with the pNFS client. 5 * 6 * Copyright (c) 2002 7 * The Regents of the University of Michigan 8 * All Rights Reserved --- 104 unchanged lines hidden (view full) --- 113 (unsigned long long)NFS_FILEID(hdr->inode), 114 hdr->args.count, 115 (unsigned long long)hdr->args.offset); 116 117 task->tk_status = pnfs_read_done_resend_to_mds(hdr); 118 } 119} 120 | 1/* 2 * Module for the pnfs nfs4 file layout driver. 3 * Defines all I/O and Policy interface operations, plus code 4 * to register itself with the pNFS client. 5 * 6 * Copyright (c) 2002 7 * The Regents of the University of Michigan 8 * All Rights Reserved --- 104 unchanged lines hidden (view full) --- 113 (unsigned long long)NFS_FILEID(hdr->inode), 114 hdr->args.count, 115 (unsigned long long)hdr->args.offset); 116 117 task->tk_status = pnfs_read_done_resend_to_mds(hdr); 118 } 119} 120 |
121static void filelayout_fenceme(struct inode *inode, struct pnfs_layout_hdr *lo) 122{ 123 if (!test_and_clear_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) 124 return; 125 pnfs_return_layout(inode); 126} 127 | |
128static int filelayout_async_handle_error(struct rpc_task *task, 129 struct nfs4_state *state, 130 struct nfs_client *clp, 131 struct pnfs_layout_segment *lseg) 132{ 133 struct pnfs_layout_hdr *lo = lseg->pls_layout; 134 struct inode *inode = lo->plh_inode; 135 struct nfs_server *mds_server = NFS_SERVER(inode); --- 198 unchanged lines hidden (view full) --- 334 335static void filelayout_read_count_stats(struct rpc_task *task, void *data) 336{ 337 struct nfs_pgio_header *hdr = data; 338 339 rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics); 340} 341 | 121static int filelayout_async_handle_error(struct rpc_task *task, 122 struct nfs4_state *state, 123 struct nfs_client *clp, 124 struct pnfs_layout_segment *lseg) 125{ 126 struct pnfs_layout_hdr *lo = lseg->pls_layout; 127 struct inode *inode = lo->plh_inode; 128 struct nfs_server *mds_server = NFS_SERVER(inode); --- 198 unchanged lines hidden (view full) --- 327 328static void filelayout_read_count_stats(struct rpc_task *task, void *data) 329{ 330 struct nfs_pgio_header *hdr = data; 331 332 rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics); 333} 334 |
342static void filelayout_read_release(void *data) 343{ 344 struct nfs_pgio_header *hdr = data; 345 struct pnfs_layout_hdr *lo = hdr->lseg->pls_layout; 346 347 filelayout_fenceme(lo->plh_inode, lo); 348 nfs_put_client(hdr->ds_clp); 349 hdr->mds_ops->rpc_release(data); 350} 351 | |
352static int filelayout_write_done_cb(struct rpc_task *task, 353 struct nfs_pgio_header *hdr) 354{ 355 int err; 356 357 trace_nfs4_pnfs_write(hdr, task->tk_status); 358 err = filelayout_async_handle_error(task, hdr->args.context->state, 359 hdr->ds_clp, hdr->lseg); --- 6 unchanged lines hidden (view full) --- 366 rpc_restart_call_prepare(task); 367 return -EAGAIN; 368 } 369 370 filelayout_set_layoutcommit(hdr); 371 return 0; 372} 373 | 335static int filelayout_write_done_cb(struct rpc_task *task, 336 struct nfs_pgio_header *hdr) 337{ 338 int err; 339 340 trace_nfs4_pnfs_write(hdr, task->tk_status); 341 err = filelayout_async_handle_error(task, hdr->args.context->state, 342 hdr->ds_clp, hdr->lseg); --- 6 unchanged lines hidden (view full) --- 349 rpc_restart_call_prepare(task); 350 return -EAGAIN; 351 } 352 353 filelayout_set_layoutcommit(hdr); 354 return 0; 355} 356 |
374/* Fake up some data that will cause nfs_commit_release to retry the writes. */ 375static void prepare_to_resend_writes(struct nfs_commit_data *data) 376{ 377 struct nfs_page *first = nfs_list_entry(data->pages.next); 378 379 data->task.tk_status = 0; 380 memcpy(&data->verf.verifier, &first->wb_verf, 381 sizeof(data->verf.verifier)); 382 data->verf.verifier.data[0]++; /* ensure verifier mismatch */ 383} 384 | |
385static int filelayout_commit_done_cb(struct rpc_task *task, 386 struct nfs_commit_data *data) 387{ 388 int err; 389 390 trace_nfs4_pnfs_commit_ds(data, task->tk_status); 391 err = filelayout_async_handle_error(task, NULL, data->ds_clp, 392 data->lseg); 393 394 switch (err) { 395 case -NFS4ERR_RESET_TO_MDS: | 357static int filelayout_commit_done_cb(struct rpc_task *task, 358 struct nfs_commit_data *data) 359{ 360 int err; 361 362 trace_nfs4_pnfs_commit_ds(data, task->tk_status); 363 err = filelayout_async_handle_error(task, NULL, data->ds_clp, 364 data->lseg); 365 366 switch (err) { 367 case -NFS4ERR_RESET_TO_MDS: |
396 prepare_to_resend_writes(data); | 368 pnfs_generic_prepare_to_resend_writes(data); |
397 return -EAGAIN; 398 case -EAGAIN: 399 rpc_restart_call_prepare(task); 400 return -EAGAIN; 401 } 402 403 if (data->verf.committed == NFS_UNSTABLE) 404 pnfs_commit_set_layoutcommit(data); --- 41 unchanged lines hidden (view full) --- 446 447static void filelayout_write_count_stats(struct rpc_task *task, void *data) 448{ 449 struct nfs_pgio_header *hdr = data; 450 451 rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics); 452} 453 | 369 return -EAGAIN; 370 case -EAGAIN: 371 rpc_restart_call_prepare(task); 372 return -EAGAIN; 373 } 374 375 if (data->verf.committed == NFS_UNSTABLE) 376 pnfs_commit_set_layoutcommit(data); --- 41 unchanged lines hidden (view full) --- 418 419static void filelayout_write_count_stats(struct rpc_task *task, void *data) 420{ 421 struct nfs_pgio_header *hdr = data; 422 423 rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics); 424} 425 |
454static void filelayout_write_release(void *data) 455{ 456 struct nfs_pgio_header *hdr = data; 457 struct pnfs_layout_hdr *lo = hdr->lseg->pls_layout; 458 459 filelayout_fenceme(lo->plh_inode, lo); 460 nfs_put_client(hdr->ds_clp); 461 hdr->mds_ops->rpc_release(data); 462} 463 | |
464static void filelayout_commit_prepare(struct rpc_task *task, void *data) 465{ 466 struct nfs_commit_data *wdata = data; 467 468 nfs41_setup_sequence(wdata->ds_clp->cl_session, 469 &wdata->args.seq_args, 470 &wdata->res.seq_res, 471 task); 472} 473 | 426static void filelayout_commit_prepare(struct rpc_task *task, void *data) 427{ 428 struct nfs_commit_data *wdata = data; 429 430 nfs41_setup_sequence(wdata->ds_clp->cl_session, 431 &wdata->args.seq_args, 432 &wdata->res.seq_res, 433 task); 434} 435 |
474static void filelayout_write_commit_done(struct rpc_task *task, void *data) 475{ 476 struct nfs_commit_data *wdata = data; 477 478 /* Note this may cause RPC to be resent */ 479 wdata->mds_ops->rpc_call_done(task, data); 480} 481 | |
482static void filelayout_commit_count_stats(struct rpc_task *task, void *data) 483{ 484 struct nfs_commit_data *cdata = data; 485 486 rpc_count_iostats(task, NFS_SERVER(cdata->inode)->client->cl_metrics); 487} 488 | 436static void filelayout_commit_count_stats(struct rpc_task *task, void *data) 437{ 438 struct nfs_commit_data *cdata = data; 439 440 rpc_count_iostats(task, NFS_SERVER(cdata->inode)->client->cl_metrics); 441} 442 |
489static void filelayout_commit_release(void *calldata) 490{ 491 struct nfs_commit_data *data = calldata; 492 493 data->completion_ops->completion(data); 494 pnfs_put_lseg(data->lseg); 495 nfs_put_client(data->ds_clp); 496 nfs_commitdata_release(data); 497} 498 | |
499static const struct rpc_call_ops filelayout_read_call_ops = { 500 .rpc_call_prepare = filelayout_read_prepare, 501 .rpc_call_done = filelayout_read_call_done, 502 .rpc_count_stats = filelayout_read_count_stats, | 443static const struct rpc_call_ops filelayout_read_call_ops = { 444 .rpc_call_prepare = filelayout_read_prepare, 445 .rpc_call_done = filelayout_read_call_done, 446 .rpc_count_stats = filelayout_read_count_stats, |
503 .rpc_release = filelayout_read_release, | 447 .rpc_release = pnfs_generic_rw_release, |
504}; 505 506static const struct rpc_call_ops filelayout_write_call_ops = { 507 .rpc_call_prepare = filelayout_write_prepare, 508 .rpc_call_done = filelayout_write_call_done, 509 .rpc_count_stats = filelayout_write_count_stats, | 448}; 449 450static const struct rpc_call_ops filelayout_write_call_ops = { 451 .rpc_call_prepare = filelayout_write_prepare, 452 .rpc_call_done = filelayout_write_call_done, 453 .rpc_count_stats = filelayout_write_count_stats, |
510 .rpc_release = filelayout_write_release, | 454 .rpc_release = pnfs_generic_rw_release, |
511}; 512 513static const struct rpc_call_ops filelayout_commit_call_ops = { 514 .rpc_call_prepare = filelayout_commit_prepare, | 455}; 456 457static const struct rpc_call_ops filelayout_commit_call_ops = { 458 .rpc_call_prepare = filelayout_commit_prepare, |
515 .rpc_call_done = filelayout_write_commit_done, | 459 .rpc_call_done = pnfs_generic_write_commit_done, |
516 .rpc_count_stats = filelayout_commit_count_stats, | 460 .rpc_count_stats = filelayout_commit_count_stats, |
517 .rpc_release = filelayout_commit_release, | 461 .rpc_release = pnfs_generic_commit_release, |
518}; 519 520static enum pnfs_try_status 521filelayout_read_pagelist(struct nfs_pgio_header *hdr) 522{ 523 struct pnfs_layout_segment *lseg = hdr->lseg; 524 struct nfs4_pnfs_ds *ds; 525 struct rpc_clnt *ds_clnt; --- 473 unchanged lines hidden (view full) --- 999static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j) 1000{ 1001 if (fl->stripe_type == STRIPE_SPARSE) 1002 return nfs4_fl_calc_ds_index(&fl->generic_hdr, j); 1003 else 1004 return j; 1005} 1006 | 462}; 463 464static enum pnfs_try_status 465filelayout_read_pagelist(struct nfs_pgio_header *hdr) 466{ 467 struct pnfs_layout_segment *lseg = hdr->lseg; 468 struct nfs4_pnfs_ds *ds; 469 struct rpc_clnt *ds_clnt; --- 473 unchanged lines hidden (view full) --- 943static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j) 944{ 945 if (fl->stripe_type == STRIPE_SPARSE) 946 return nfs4_fl_calc_ds_index(&fl->generic_hdr, j); 947 else 948 return j; 949} 950 |
1007/* The generic layer is about to remove the req from the commit list. 1008 * If this will make the bucket empty, it will need to put the lseg reference. 1009 * Note this is must be called holding the inode (/cinfo) lock 1010 */ | |
1011static void | 951static void |
1012filelayout_clear_request_commit(struct nfs_page *req, 1013 struct nfs_commit_info *cinfo) 1014{ 1015 struct pnfs_layout_segment *freeme = NULL; 1016 1017 if (!test_and_clear_bit(PG_COMMIT_TO_DS, &req->wb_flags)) 1018 goto out; 1019 cinfo->ds->nwritten--; 1020 if (list_is_singular(&req->wb_list)) { 1021 struct pnfs_commit_bucket *bucket; 1022 1023 bucket = list_first_entry(&req->wb_list, 1024 struct pnfs_commit_bucket, 1025 written); 1026 freeme = bucket->wlseg; 1027 bucket->wlseg = NULL; 1028 } 1029out: 1030 nfs_request_remove_commit_list(req, cinfo); 1031 pnfs_put_lseg_locked(freeme); 1032} 1033 1034static void | |
1035filelayout_mark_request_commit(struct nfs_page *req, 1036 struct pnfs_layout_segment *lseg, 1037 struct nfs_commit_info *cinfo) 1038 1039{ 1040 struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg); 1041 u32 i, j; 1042 struct list_head *list; --- 16 unchanged lines hidden (view full) --- 1059 spin_lock(cinfo->lock); 1060 buckets = cinfo->ds->buckets; 1061 list = &buckets[i].written; 1062 if (list_empty(list)) { 1063 /* Non-empty buckets hold a reference on the lseg. That ref 1064 * is normally transferred to the COMMIT call and released 1065 * there. It could also be released if the last req is pulled 1066 * off due to a rewrite, in which case it will be done in | 952filelayout_mark_request_commit(struct nfs_page *req, 953 struct pnfs_layout_segment *lseg, 954 struct nfs_commit_info *cinfo) 955 956{ 957 struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg); 958 u32 i, j; 959 struct list_head *list; --- 16 unchanged lines hidden (view full) --- 976 spin_lock(cinfo->lock); 977 buckets = cinfo->ds->buckets; 978 list = &buckets[i].written; 979 if (list_empty(list)) { 980 /* Non-empty buckets hold a reference on the lseg. That ref 981 * is normally transferred to the COMMIT call and released 982 * there. It could also be released if the last req is pulled 983 * off due to a rewrite, in which case it will be done in |
1067 * filelayout_clear_request_commit | 984 * pnfs_generic_clear_request_commit |
1068 */ 1069 buckets[i].wlseg = pnfs_get_lseg(lseg); 1070 } 1071 set_bit(PG_COMMIT_TO_DS, &req->wb_flags); 1072 cinfo->ds->nwritten++; 1073 1074mds_commit: 1075 /* nfs_request_add_commit_list(). We need to add req to list without 1076 * dropping cinfo lock. 1077 */ 1078 set_bit(PG_CLEAN, &(req)->wb_flags); 1079 nfs_list_add_request(req, list); 1080 cinfo->mds->ncommit++; 1081 spin_unlock(cinfo->lock); 1082 if (!cinfo->dreq) { 1083 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); | 985 */ 986 buckets[i].wlseg = pnfs_get_lseg(lseg); 987 } 988 set_bit(PG_COMMIT_TO_DS, &req->wb_flags); 989 cinfo->ds->nwritten++; 990 991mds_commit: 992 /* nfs_request_add_commit_list(). We need to add req to list without 993 * dropping cinfo lock. 994 */ 995 set_bit(PG_CLEAN, &(req)->wb_flags); 996 nfs_list_add_request(req, list); 997 cinfo->mds->ncommit++; 998 spin_unlock(cinfo->lock); 999 if (!cinfo->dreq) { 1000 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); |
1084 inc_bdi_stat(inode_to_bdi(page_file_mapping(req->wb_page)->host), | 1001 inc_bdi_stat(page_file_mapping(req->wb_page)->backing_dev_info, |
1085 BDI_RECLAIMABLE); 1086 __mark_inode_dirty(req->wb_context->dentry->d_inode, 1087 I_DIRTY_DATASYNC); 1088 } 1089} 1090 1091static u32 calc_ds_index_from_commit(struct pnfs_layout_segment *lseg, u32 i) 1092{ --- 44 unchanged lines hidden (view full) --- 1137 data->ds_clp = ds->ds_clp; 1138 fh = select_ds_fh_from_commit(lseg, data->ds_commit_index); 1139 if (fh) 1140 data->args.fh = fh; 1141 return nfs_initiate_commit(ds_clnt, data, 1142 &filelayout_commit_call_ops, how, 1143 RPC_TASK_SOFTCONN); 1144out_err: | 1002 BDI_RECLAIMABLE); 1003 __mark_inode_dirty(req->wb_context->dentry->d_inode, 1004 I_DIRTY_DATASYNC); 1005 } 1006} 1007 1008static u32 calc_ds_index_from_commit(struct pnfs_layout_segment *lseg, u32 i) 1009{ --- 44 unchanged lines hidden (view full) --- 1054 data->ds_clp = ds->ds_clp; 1055 fh = select_ds_fh_from_commit(lseg, data->ds_commit_index); 1056 if (fh) 1057 data->args.fh = fh; 1058 return nfs_initiate_commit(ds_clnt, data, 1059 &filelayout_commit_call_ops, how, 1060 RPC_TASK_SOFTCONN); 1061out_err: |
1145 prepare_to_resend_writes(data); 1146 filelayout_commit_release(data); | 1062 pnfs_generic_prepare_to_resend_writes(data); 1063 pnfs_generic_commit_release(data); |
1147 return -EAGAIN; 1148} 1149 | 1064 return -EAGAIN; 1065} 1066 |
1150static int 1151transfer_commit_list(struct list_head *src, struct list_head *dst, 1152 struct nfs_commit_info *cinfo, int max) 1153{ 1154 struct nfs_page *req, *tmp; 1155 int ret = 0; 1156 1157 list_for_each_entry_safe(req, tmp, src, wb_list) { 1158 if (!nfs_lock_request(req)) 1159 continue; 1160 kref_get(&req->wb_kref); 1161 if (cond_resched_lock(cinfo->lock)) 1162 list_safe_reset_next(req, tmp, wb_list); 1163 nfs_request_remove_commit_list(req, cinfo); 1164 clear_bit(PG_COMMIT_TO_DS, &req->wb_flags); 1165 nfs_list_add_request(req, dst); 1166 ret++; 1167 if ((ret == max) && !cinfo->dreq) 1168 break; 1169 } 1170 return ret; 1171} 1172 1173/* Note called with cinfo->lock held. */ 1174static int 1175filelayout_scan_ds_commit_list(struct pnfs_commit_bucket *bucket, 1176 struct nfs_commit_info *cinfo, 1177 int max) 1178{ 1179 struct list_head *src = &bucket->written; 1180 struct list_head *dst = &bucket->committing; 1181 int ret; 1182 1183 ret = transfer_commit_list(src, dst, cinfo, max); 1184 if (ret) { 1185 cinfo->ds->nwritten -= ret; 1186 cinfo->ds->ncommitting += ret; 1187 bucket->clseg = bucket->wlseg; 1188 if (list_empty(src)) 1189 bucket->wlseg = NULL; 1190 else 1191 pnfs_get_lseg(bucket->clseg); 1192 } 1193 return ret; 1194} 1195 1196/* Move reqs from written to committing lists, returning count of number moved. 1197 * Note called with cinfo->lock held. 1198 */ 1199static int filelayout_scan_commit_lists(struct nfs_commit_info *cinfo, 1200 int max) 1201{ 1202 int i, rv = 0, cnt; 1203 1204 for (i = 0; i < cinfo->ds->nbuckets && max != 0; i++) { 1205 cnt = filelayout_scan_ds_commit_list(&cinfo->ds->buckets[i], 1206 cinfo, max); 1207 max -= cnt; 1208 rv += cnt; 1209 } 1210 return rv; 1211} 1212 1213/* Pull everything off the committing lists and dump into @dst */ 1214static void filelayout_recover_commit_reqs(struct list_head *dst, 1215 struct nfs_commit_info *cinfo) 1216{ 1217 struct pnfs_commit_bucket *b; 1218 struct pnfs_layout_segment *freeme; 1219 int i; 1220 1221restart: 1222 spin_lock(cinfo->lock); 1223 for (i = 0, b = cinfo->ds->buckets; i < cinfo->ds->nbuckets; i++, b++) { 1224 if (transfer_commit_list(&b->written, dst, cinfo, 0)) { 1225 freeme = b->wlseg; 1226 b->wlseg = NULL; 1227 spin_unlock(cinfo->lock); 1228 pnfs_put_lseg(freeme); 1229 goto restart; 1230 } 1231 } 1232 cinfo->ds->nwritten = 0; 1233 spin_unlock(cinfo->lock); 1234} 1235 | |
1236/* filelayout_search_commit_reqs - Search lists in @cinfo for the head reqest 1237 * for @page 1238 * @cinfo - commit info for current inode 1239 * @page - page to search for matching head request 1240 * 1241 * Returns a the head request if one is found, otherwise returns NULL. 1242 */ 1243static struct nfs_page * --- 14 unchanged lines hidden (view full) --- 1258 if (freq->wb_page == page) 1259 return freq->wb_head; 1260 } 1261 } 1262 1263 return NULL; 1264} 1265 | 1067/* filelayout_search_commit_reqs - Search lists in @cinfo for the head reqest 1068 * for @page 1069 * @cinfo - commit info for current inode 1070 * @page - page to search for matching head request 1071 * 1072 * Returns a the head request if one is found, otherwise returns NULL. 1073 */ 1074static struct nfs_page * --- 14 unchanged lines hidden (view full) --- 1089 if (freq->wb_page == page) 1090 return freq->wb_head; 1091 } 1092 } 1093 1094 return NULL; 1095} 1096 |
1266static void filelayout_retry_commit(struct nfs_commit_info *cinfo, int idx) 1267{ 1268 struct pnfs_ds_commit_info *fl_cinfo = cinfo->ds; 1269 struct pnfs_commit_bucket *bucket; 1270 struct pnfs_layout_segment *freeme; 1271 int i; 1272 1273 for (i = idx; i < fl_cinfo->nbuckets; i++) { 1274 bucket = &fl_cinfo->buckets[i]; 1275 if (list_empty(&bucket->committing)) 1276 continue; 1277 nfs_retry_commit(&bucket->committing, bucket->clseg, cinfo); 1278 spin_lock(cinfo->lock); 1279 freeme = bucket->clseg; 1280 bucket->clseg = NULL; 1281 spin_unlock(cinfo->lock); 1282 pnfs_put_lseg(freeme); 1283 } 1284} 1285 1286static unsigned int 1287alloc_ds_commits(struct nfs_commit_info *cinfo, struct list_head *list) 1288{ 1289 struct pnfs_ds_commit_info *fl_cinfo; 1290 struct pnfs_commit_bucket *bucket; 1291 struct nfs_commit_data *data; 1292 int i; 1293 unsigned int nreq = 0; 1294 1295 fl_cinfo = cinfo->ds; 1296 bucket = fl_cinfo->buckets; 1297 for (i = 0; i < fl_cinfo->nbuckets; i++, bucket++) { 1298 if (list_empty(&bucket->committing)) 1299 continue; 1300 data = nfs_commitdata_alloc(); 1301 if (!data) 1302 break; 1303 data->ds_commit_index = i; 1304 spin_lock(cinfo->lock); 1305 data->lseg = bucket->clseg; 1306 bucket->clseg = NULL; 1307 spin_unlock(cinfo->lock); 1308 list_add(&data->pages, list); 1309 nreq++; 1310 } 1311 1312 /* Clean up on error */ 1313 filelayout_retry_commit(cinfo, i); 1314 /* Caller will clean up entries put on list */ 1315 return nreq; 1316} 1317 1318/* This follows nfs_commit_list pretty closely */ | |
1319static int 1320filelayout_commit_pagelist(struct inode *inode, struct list_head *mds_pages, 1321 int how, struct nfs_commit_info *cinfo) 1322{ | 1097static int 1098filelayout_commit_pagelist(struct inode *inode, struct list_head *mds_pages, 1099 int how, struct nfs_commit_info *cinfo) 1100{ |
1323 struct nfs_commit_data *data, *tmp; 1324 LIST_HEAD(list); 1325 unsigned int nreq = 0; 1326 1327 if (!list_empty(mds_pages)) { 1328 data = nfs_commitdata_alloc(); 1329 if (data != NULL) { 1330 data->lseg = NULL; 1331 list_add(&data->pages, &list); 1332 nreq++; 1333 } else { 1334 nfs_retry_commit(mds_pages, NULL, cinfo); 1335 filelayout_retry_commit(cinfo, 0); 1336 cinfo->completion_ops->error_cleanup(NFS_I(inode)); 1337 return -ENOMEM; 1338 } 1339 } 1340 1341 nreq += alloc_ds_commits(cinfo, &list); 1342 1343 if (nreq == 0) { 1344 cinfo->completion_ops->error_cleanup(NFS_I(inode)); 1345 goto out; 1346 } 1347 1348 atomic_add(nreq, &cinfo->mds->rpcs_out); 1349 1350 list_for_each_entry_safe(data, tmp, &list, pages) { 1351 list_del_init(&data->pages); 1352 if (!data->lseg) { 1353 nfs_init_commit(data, mds_pages, NULL, cinfo); 1354 nfs_initiate_commit(NFS_CLIENT(inode), data, 1355 data->mds_ops, how, 0); 1356 } else { 1357 struct pnfs_commit_bucket *buckets; 1358 1359 buckets = cinfo->ds->buckets; 1360 nfs_init_commit(data, &buckets[data->ds_commit_index].committing, data->lseg, cinfo); 1361 filelayout_initiate_commit(data, how); 1362 } 1363 } 1364out: 1365 cinfo->ds->ncommitting = 0; 1366 return PNFS_ATTEMPTED; | 1101 return pnfs_generic_commit_pagelist(inode, mds_pages, how, cinfo, 1102 filelayout_initiate_commit); |
1367} | 1103} |
1104 |
|
1368static struct nfs4_deviceid_node * 1369filelayout_alloc_deviceid_node(struct nfs_server *server, 1370 struct pnfs_device *pdev, gfp_t gfp_flags) 1371{ 1372 struct nfs4_file_layout_dsaddr *dsaddr; 1373 1374 dsaddr = nfs4_fl_alloc_deviceid_node(server, pdev, gfp_flags); 1375 if (!dsaddr) --- 40 unchanged lines hidden (view full) --- 1416 .alloc_layout_hdr = filelayout_alloc_layout_hdr, 1417 .free_layout_hdr = filelayout_free_layout_hdr, 1418 .alloc_lseg = filelayout_alloc_lseg, 1419 .free_lseg = filelayout_free_lseg, 1420 .pg_read_ops = &filelayout_pg_read_ops, 1421 .pg_write_ops = &filelayout_pg_write_ops, 1422 .get_ds_info = &filelayout_get_ds_info, 1423 .mark_request_commit = filelayout_mark_request_commit, | 1105static struct nfs4_deviceid_node * 1106filelayout_alloc_deviceid_node(struct nfs_server *server, 1107 struct pnfs_device *pdev, gfp_t gfp_flags) 1108{ 1109 struct nfs4_file_layout_dsaddr *dsaddr; 1110 1111 dsaddr = nfs4_fl_alloc_deviceid_node(server, pdev, gfp_flags); 1112 if (!dsaddr) --- 40 unchanged lines hidden (view full) --- 1153 .alloc_layout_hdr = filelayout_alloc_layout_hdr, 1154 .free_layout_hdr = filelayout_free_layout_hdr, 1155 .alloc_lseg = filelayout_alloc_lseg, 1156 .free_lseg = filelayout_free_lseg, 1157 .pg_read_ops = &filelayout_pg_read_ops, 1158 .pg_write_ops = &filelayout_pg_write_ops, 1159 .get_ds_info = &filelayout_get_ds_info, 1160 .mark_request_commit = filelayout_mark_request_commit, |
1424 .clear_request_commit = filelayout_clear_request_commit, 1425 .scan_commit_lists = filelayout_scan_commit_lists, 1426 .recover_commit_reqs = filelayout_recover_commit_reqs, | 1161 .clear_request_commit = pnfs_generic_clear_request_commit, 1162 .scan_commit_lists = pnfs_generic_scan_commit_lists, 1163 .recover_commit_reqs = pnfs_generic_recover_commit_reqs, |
1427 .search_commit_reqs = filelayout_search_commit_reqs, 1428 .commit_pagelist = filelayout_commit_pagelist, 1429 .read_pagelist = filelayout_read_pagelist, 1430 .write_pagelist = filelayout_write_pagelist, 1431 .alloc_deviceid_node = filelayout_alloc_deviceid_node, 1432 .free_deviceid_node = filelayout_free_deveiceid_node, 1433}; 1434 --- 18 unchanged lines hidden --- | 1164 .search_commit_reqs = filelayout_search_commit_reqs, 1165 .commit_pagelist = filelayout_commit_pagelist, 1166 .read_pagelist = filelayout_read_pagelist, 1167 .write_pagelist = filelayout_write_pagelist, 1168 .alloc_deviceid_node = filelayout_alloc_deviceid_node, 1169 .free_deviceid_node = filelayout_free_deveiceid_node, 1170}; 1171 --- 18 unchanged lines hidden --- |