Lines Matching +full:data +full:- +full:mirror
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (c) 2014, Primary Data, Inc. All rights reserved.
29 nfs4_put_deviceid_node(&mirror_ds->id_node); in nfs4_ff_layout_put_deviceid()
34 nfs4_print_deviceid(&mirror_ds->id_node.deviceid); in nfs4_ff_layout_free_deviceid()
35 nfs4_pnfs_ds_put(mirror_ds->ds); in nfs4_ff_layout_free_deviceid()
36 kfree(mirror_ds->ds_versions); in nfs4_ff_layout_free_deviceid()
40 /* Decode opaque device data and construct new_ds using it */
55 int i, ret = -ENOMEM; in nfs4_ff_alloc_deviceid_node()
66 nfs4_init_deviceid_node(&new_ds->id_node, in nfs4_ff_alloc_deviceid_node()
68 &pdev->dev_id); in nfs4_ff_alloc_deviceid_node()
71 xdr_init_decode_pages(&stream, &buf, pdev->pages, pdev->pglen); in nfs4_ff_alloc_deviceid_node()
83 da = nfs4_decode_mp_ds_addr(server->nfs_client->cl_net, in nfs4_ff_alloc_deviceid_node()
86 list_add_tail(&da->da_node, &dsaddrs); in nfs4_ff_alloc_deviceid_node()
91 ret = -ENOMEDIUM; in nfs4_ff_alloc_deviceid_node()
117 server->nfs_client->cl_proto); in nfs4_ff_alloc_deviceid_node()
119 server->nfs_client->cl_proto); in nfs4_ff_alloc_deviceid_node()
134 dprintk("%s: [%d] unsupported ds version %d-%d\n", __func__, in nfs4_ff_alloc_deviceid_node()
137 ret = -EPROTONOSUPPORT; in nfs4_ff_alloc_deviceid_node()
149 new_ds->ds_versions = ds_versions; in nfs4_ff_alloc_deviceid_node()
150 new_ds->ds_versions_cnt = version_count; in nfs4_ff_alloc_deviceid_node()
152 new_ds->ds = nfs4_pnfs_ds_add(&dsaddrs, gfp_flags); in nfs4_ff_alloc_deviceid_node()
153 if (!new_ds->ds) in nfs4_ff_alloc_deviceid_node()
161 list_del_init(&da->da_node); in nfs4_ff_alloc_deviceid_node()
162 kfree(da->da_remotestr); in nfs4_ff_alloc_deviceid_node()
173 list_del_init(&da->da_node); in nfs4_ff_alloc_deviceid_node()
174 kfree(da->da_remotestr); in nfs4_ff_alloc_deviceid_node()
193 end = max_t(u64, pnfs_end_offset(err->offset, err->length), in extend_ds_error()
195 err->offset = min_t(u64, err->offset, offset); in extend_ds_error()
196 err->length = end - err->offset; in extend_ds_error()
205 if (e1->opnum != e2->opnum) in ff_ds_error_match()
206 return e1->opnum < e2->opnum ? -1 : 1; in ff_ds_error_match()
207 if (e1->status != e2->status) in ff_ds_error_match()
208 return e1->status < e2->status ? -1 : 1; in ff_ds_error_match()
209 ret = memcmp(e1->stateid.data, e2->stateid.data, in ff_ds_error_match()
210 sizeof(e1->stateid.data)); in ff_ds_error_match()
213 ret = memcmp(&e1->deviceid, &e2->deviceid, sizeof(e1->deviceid)); in ff_ds_error_match()
216 if (pnfs_end_offset(e1->offset, e1->length) < e2->offset) in ff_ds_error_match()
217 return -1; in ff_ds_error_match()
218 if (e1->offset > pnfs_end_offset(e2->offset, e2->length)) in ff_ds_error_match()
229 struct list_head *head = &flo->error_list; in ff_layout_add_ds_error_locked()
233 list_for_each_entry_safe(err, tmp, &flo->error_list, list) { in ff_layout_add_ds_error_locked()
239 head = &err->list; in ff_layout_add_ds_error_locked()
243 extend_ds_error(dserr, err->offset, err->length); in ff_layout_add_ds_error_locked()
244 list_replace(&err->list, &dserr->list); in ff_layout_add_ds_error_locked()
249 list_add_tail(&dserr->list, head); in ff_layout_add_ds_error_locked()
253 struct nfs4_ff_layout_mirror *mirror, u64 offset, in ff_layout_track_ds_error() argument
262 if (IS_ERR_OR_NULL(mirror->mirror_ds)) in ff_layout_track_ds_error()
263 return -EINVAL; in ff_layout_track_ds_error()
267 return -ENOMEM; in ff_layout_track_ds_error()
269 INIT_LIST_HEAD(&dserr->list); in ff_layout_track_ds_error()
270 dserr->offset = offset; in ff_layout_track_ds_error()
271 dserr->length = length; in ff_layout_track_ds_error()
272 dserr->status = status; in ff_layout_track_ds_error()
273 dserr->opnum = opnum; in ff_layout_track_ds_error()
274 nfs4_stateid_copy(&dserr->stateid, &mirror->stateid); in ff_layout_track_ds_error()
275 memcpy(&dserr->deviceid, &mirror->mirror_ds->id_node.deviceid, in ff_layout_track_ds_error()
278 spin_lock(&flo->generic_hdr.plh_inode->i_lock); in ff_layout_track_ds_error()
280 spin_unlock(&flo->generic_hdr.plh_inode->i_lock); in ff_layout_track_ds_error()
285 ff_layout_get_mirror_cred(struct nfs4_ff_layout_mirror *mirror, u32 iomode) in ff_layout_get_mirror_cred() argument
290 pcred = &mirror->ro_cred; in ff_layout_get_mirror_cred()
292 pcred = &mirror->rw_cred; in ff_layout_get_mirror_cred()
307 nfs4_ff_layout_select_ds_fh(struct nfs4_ff_layout_mirror *mirror) in nfs4_ff_layout_select_ds_fh() argument
310 return &mirror->fh_versions[0]; in nfs4_ff_layout_select_ds_fh()
314 nfs4_ff_layout_select_ds_stateid(const struct nfs4_ff_layout_mirror *mirror, in nfs4_ff_layout_select_ds_stateid() argument
317 if (nfs4_ff_layout_ds_version(mirror) == 4) in nfs4_ff_layout_select_ds_stateid()
318 nfs4_stateid_copy(stateid, &mirror->stateid); in nfs4_ff_layout_select_ds_stateid()
323 struct nfs4_ff_layout_mirror *mirror) in ff_layout_init_mirror_ds() argument
325 if (mirror == NULL) in ff_layout_init_mirror_ds()
327 if (mirror->mirror_ds == NULL) { in ff_layout_init_mirror_ds()
329 struct nfs4_ff_layout_ds *mirror_ds = ERR_PTR(-ENODEV); in ff_layout_init_mirror_ds()
331 node = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode), in ff_layout_init_mirror_ds()
332 &mirror->devid, lo->plh_lc_cred, in ff_layout_init_mirror_ds()
338 if (cmpxchg(&mirror->mirror_ds, NULL, mirror_ds) && in ff_layout_init_mirror_ds()
339 mirror_ds != ERR_PTR(-ENODEV)) in ff_layout_init_mirror_ds()
343 if (IS_ERR(mirror->mirror_ds)) in ff_layout_init_mirror_ds()
352 * nfs4_ff_layout_prepare_ds - prepare a DS connection for an RPC call
354 * @mirror: layout mirror describing the DS to use
358 * selecting a mirror to use and connecting the client to it if it's not
361 * Since we only need a single functioning mirror to satisfy a read, we don't
363 * mirror should result in a LAYOUTRETURN. @fail_return is how we distinguish
370 struct nfs4_ff_layout_mirror *mirror, in nfs4_ff_layout_prepare_ds() argument
374 struct inode *ino = lseg->pls_layout->plh_inode; in nfs4_ff_layout_prepare_ds()
379 if (!ff_layout_init_mirror_ds(lseg->pls_layout, mirror)) in nfs4_ff_layout_prepare_ds()
382 ds = mirror->mirror_ds->ds; in nfs4_ff_layout_prepare_ds()
383 if (READ_ONCE(ds->ds_clp)) in nfs4_ff_layout_prepare_ds()
391 status = nfs4_pnfs_ds_connect(s, ds, &mirror->mirror_ds->id_node, in nfs4_ff_layout_prepare_ds()
393 mirror->mirror_ds->ds_versions[0].version, in nfs4_ff_layout_prepare_ds()
394 mirror->mirror_ds->ds_versions[0].minor_version); in nfs4_ff_layout_prepare_ds()
399 nfs_block_size(rpc_max_payload(ds->ds_clp->cl_rpcclient), in nfs4_ff_layout_prepare_ds()
401 if (mirror->mirror_ds->ds_versions[0].rsize > max_payload) in nfs4_ff_layout_prepare_ds()
402 mirror->mirror_ds->ds_versions[0].rsize = max_payload; in nfs4_ff_layout_prepare_ds()
403 if (mirror->mirror_ds->ds_versions[0].wsize > max_payload) in nfs4_ff_layout_prepare_ds()
404 mirror->mirror_ds->ds_versions[0].wsize = max_payload; in nfs4_ff_layout_prepare_ds()
408 ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout), in nfs4_ff_layout_prepare_ds()
409 mirror, lseg->pls_range.offset, in nfs4_ff_layout_prepare_ds()
410 lseg->pls_range.length, NFS4ERR_NXIO, in nfs4_ff_layout_prepare_ds()
421 ff_layout_get_ds_cred(struct nfs4_ff_layout_mirror *mirror, in ff_layout_get_ds_cred() argument
427 if (mirror && !mirror->mirror_ds->ds_versions[0].tightly_coupled) { in ff_layout_get_ds_cred()
428 cred = ff_layout_get_mirror_cred(mirror, range->iomode); in ff_layout_get_ds_cred()
438 * nfs4_ff_find_or_create_ds_client - Find or create a DS rpc client
439 * @mirror: pointer to the mirror
447 nfs4_ff_find_or_create_ds_client(struct nfs4_ff_layout_mirror *mirror, in nfs4_ff_find_or_create_ds_client() argument
450 switch (mirror->mirror_ds->ds_versions[0].version) { in nfs4_ff_find_or_create_ds_client()
453 return ds_clp->cl_rpcclient; in nfs4_ff_find_or_create_ds_client()
469 list_del(&err->list); in ff_layout_free_ds_ioerr()
488 return -ENOBUFS; in ff_layout_encode_ds_ioerr()
489 p = xdr_encode_hyper(p, err->offset); in ff_layout_encode_ds_ioerr()
490 p = xdr_encode_hyper(p, err->length); in ff_layout_encode_ds_ioerr()
491 p = xdr_encode_opaque_fixed(p, &err->stateid, in ff_layout_encode_ds_ioerr()
495 p = xdr_encode_opaque_fixed(p, &err->deviceid, in ff_layout_encode_ds_ioerr()
497 *p++ = cpu_to_be32(err->status); in ff_layout_encode_ds_ioerr()
498 *p++ = cpu_to_be32(err->opnum); in ff_layout_encode_ds_ioerr()
500 __func__, err->offset, err->length, err->status, in ff_layout_encode_ds_ioerr()
501 err->opnum); in ff_layout_encode_ds_ioerr()
514 struct inode *inode = lo->plh_inode; in do_layout_fetch_ds_ioerr()
518 spin_lock(&inode->i_lock); in do_layout_fetch_ds_ioerr()
519 list_for_each_entry_safe(err, n, &flo->error_list, list) { in do_layout_fetch_ds_ioerr()
520 if (!pnfs_is_range_intersecting(err->offset, in do_layout_fetch_ds_ioerr()
521 pnfs_end_offset(err->offset, err->length), in do_layout_fetch_ds_ioerr()
522 range->offset, in do_layout_fetch_ds_ioerr()
523 pnfs_end_offset(range->offset, range->length))) in do_layout_fetch_ds_ioerr()
527 list_move(&err->list, head); in do_layout_fetch_ds_ioerr()
528 maxnum--; in do_layout_fetch_ds_ioerr()
531 spin_unlock(&inode->i_lock); in do_layout_fetch_ds_ioerr()
546 do_layout_fetch_ds_ioerr(lo, range, &discard, -1); in ff_layout_fetch_ds_ioerr()
554 struct nfs4_ff_layout_mirror *mirror; in ff_read_layout_has_available_ds() local
559 mirror = FF_LAYOUT_COMP(lseg, idx); in ff_read_layout_has_available_ds()
560 if (mirror) { in ff_read_layout_has_available_ds()
561 if (!mirror->mirror_ds) in ff_read_layout_has_available_ds()
563 if (IS_ERR(mirror->mirror_ds)) in ff_read_layout_has_available_ds()
565 devid = &mirror->mirror_ds->id_node; in ff_read_layout_has_available_ds()
576 struct nfs4_ff_layout_mirror *mirror; in ff_rw_layout_has_available_ds() local
581 mirror = FF_LAYOUT_COMP(lseg, idx); in ff_rw_layout_has_available_ds()
582 if (!mirror || IS_ERR(mirror->mirror_ds)) in ff_rw_layout_has_available_ds()
584 if (!mirror->mirror_ds) in ff_rw_layout_has_available_ds()
586 devid = &mirror->mirror_ds->id_node; in ff_rw_layout_has_available_ds()
596 if (lseg->pls_range.iomode == IOMODE_READ) in ff_layout_has_available_ds()
610 return lseg->pls_range.iomode == IOMODE_RW && in ff_layout_avoid_read_on_rw()
621 " data server before it retries an NFS request.");