@@ -790,6 +790,19 @@ ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg,
790
790
return ff_layout_choose_any_ds_for_read (lseg , start_idx , best_idx );
791
791
}
792
792
793
+ static struct nfs4_pnfs_ds *
794
+ ff_layout_get_ds_for_read (struct nfs_pageio_descriptor * pgio , int * best_idx )
795
+ {
796
+ struct pnfs_layout_segment * lseg = pgio -> pg_lseg ;
797
+ struct nfs4_pnfs_ds * ds ;
798
+
799
+ ds = ff_layout_choose_best_ds_for_read (lseg , pgio -> pg_mirror_idx ,
800
+ best_idx );
801
+ if (ds || !pgio -> pg_mirror_idx )
802
+ return ds ;
803
+ return ff_layout_choose_best_ds_for_read (lseg , 0 , best_idx );
804
+ }
805
+
793
806
static void
794
807
ff_layout_pg_get_read (struct nfs_pageio_descriptor * pgio ,
795
808
struct nfs_page * req ,
@@ -840,7 +853,7 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio,
840
853
goto out_nolseg ;
841
854
}
842
855
843
- ds = ff_layout_choose_best_ds_for_read (pgio -> pg_lseg , 0 , & ds_idx );
856
+ ds = ff_layout_get_ds_for_read (pgio , & ds_idx );
844
857
if (!ds ) {
845
858
if (!ff_layout_no_fallback_to_mds (pgio -> pg_lseg ))
846
859
goto out_mds ;
@@ -1022,11 +1035,24 @@ static void ff_layout_reset_write(struct nfs_pgio_header *hdr, bool retry_pnfs)
1022
1035
}
1023
1036
}
1024
1037
1038
+ static void ff_layout_resend_pnfs_read (struct nfs_pgio_header * hdr )
1039
+ {
1040
+ u32 idx = hdr -> pgio_mirror_idx + 1 ;
1041
+ int new_idx = 0 ;
1042
+
1043
+ if (ff_layout_choose_any_ds_for_read (hdr -> lseg , idx + 1 , & new_idx ))
1044
+ ff_layout_send_layouterror (hdr -> lseg );
1045
+ else
1046
+ pnfs_error_mark_layout_for_return (hdr -> inode , hdr -> lseg );
1047
+ pnfs_read_resend_pnfs (hdr , new_idx );
1048
+ }
1049
+
1025
1050
static void ff_layout_reset_read (struct nfs_pgio_header * hdr )
1026
1051
{
1027
1052
struct rpc_task * task = & hdr -> task ;
1028
1053
1029
1054
pnfs_layoutcommit_inode (hdr -> inode , false);
1055
+ pnfs_error_mark_layout_for_return (hdr -> inode , hdr -> lseg );
1030
1056
1031
1057
if (!test_and_set_bit (NFS_IOHDR_REDO , & hdr -> flags )) {
1032
1058
dprintk ("%s Reset task %5u for i/o through MDS "
@@ -1228,6 +1254,12 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg,
1228
1254
break ;
1229
1255
case NFS4ERR_NXIO :
1230
1256
ff_layout_mark_ds_unreachable (lseg , idx );
1257
+ /*
1258
+ * Don't return the layout if this is a read and we still
1259
+ * have layouts to try
1260
+ */
1261
+ if (opnum == OP_READ )
1262
+ break ;
1231
1263
/* Fallthrough */
1232
1264
default :
1233
1265
pnfs_error_mark_layout_for_return (lseg -> pls_layout -> plh_inode ,
@@ -1241,7 +1273,6 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg,
1241
1273
static int ff_layout_read_done_cb (struct rpc_task * task ,
1242
1274
struct nfs_pgio_header * hdr )
1243
1275
{
1244
- int new_idx = hdr -> pgio_mirror_idx ;
1245
1276
int err ;
1246
1277
1247
1278
if (task -> tk_status < 0 ) {
@@ -1261,10 +1292,6 @@ static int ff_layout_read_done_cb(struct rpc_task *task,
1261
1292
clear_bit (NFS_IOHDR_RESEND_MDS , & hdr -> flags );
1262
1293
switch (err ) {
1263
1294
case - NFS4ERR_RESET_TO_PNFS :
1264
- if (ff_layout_choose_best_ds_for_read (hdr -> lseg ,
1265
- hdr -> pgio_mirror_idx + 1 ,
1266
- & new_idx ))
1267
- goto out_layouterror ;
1268
1295
set_bit (NFS_IOHDR_RESEND_PNFS , & hdr -> flags );
1269
1296
return task -> tk_status ;
1270
1297
case - NFS4ERR_RESET_TO_MDS :
@@ -1275,10 +1302,6 @@ static int ff_layout_read_done_cb(struct rpc_task *task,
1275
1302
}
1276
1303
1277
1304
return 0 ;
1278
- out_layouterror :
1279
- ff_layout_read_record_layoutstats_done (task , hdr );
1280
- ff_layout_send_layouterror (hdr -> lseg );
1281
- hdr -> pgio_mirror_idx = new_idx ;
1282
1305
out_eagain :
1283
1306
rpc_restart_call_prepare (task );
1284
1307
return - EAGAIN ;
@@ -1405,10 +1428,9 @@ static void ff_layout_read_release(void *data)
1405
1428
struct nfs_pgio_header * hdr = data ;
1406
1429
1407
1430
ff_layout_read_record_layoutstats_done (& hdr -> task , hdr );
1408
- if (test_bit (NFS_IOHDR_RESEND_PNFS , & hdr -> flags )) {
1409
- ff_layout_send_layouterror (hdr -> lseg );
1410
- pnfs_read_resend_pnfs (hdr );
1411
- } else if (test_bit (NFS_IOHDR_RESEND_MDS , & hdr -> flags ))
1431
+ if (test_bit (NFS_IOHDR_RESEND_PNFS , & hdr -> flags ))
1432
+ ff_layout_resend_pnfs_read (hdr );
1433
+ else if (test_bit (NFS_IOHDR_RESEND_MDS , & hdr -> flags ))
1412
1434
ff_layout_reset_read (hdr );
1413
1435
pnfs_generic_rw_release (data );
1414
1436
}
0 commit comments