ReactOS 0.4.15-dev-7089-gea8a49d
nfs41_ops.c File Reference
#include <windows.h>
#include <strsafe.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "nfs41_ops.h"
#include "nfs41_compound.h"
#include "nfs41_xdr.h"
#include "name_cache.h"
#include "delegation.h"
#include "daemon_debug.h"
#include "util.h"
Include dependency graph for nfs41_ops.c:

Go to the source code of this file.

Functions

int nfs41_exchange_id (IN nfs41_rpc_clnt *rpc, IN client_owner4 *owner, IN uint32_t flags_in, OUT nfs41_exchange_id_res *res_out)
 
static int set_fore_channel_attrs (IN nfs41_rpc_clnt *rpc, IN uint32_t max_req, OUT nfs41_channel_attrs *attrs)
 
static int set_back_channel_attrs (IN nfs41_rpc_clnt *rpc, IN uint32_t max_req, OUT nfs41_channel_attrs *attrs)
 
int nfs41_create_session (nfs41_client *clnt, nfs41_session *session, bool_t try_recovery)
 
enum nfsstat4 nfs41_bind_conn_to_session (IN nfs41_rpc_clnt *rpc, IN const unsigned char *sessionid, IN enum channel_dir_from_client4 dir)
 
int nfs41_destroy_session (IN nfs41_session *session)
 
int nfs41_destroy_clientid (IN nfs41_rpc_clnt *rpc, IN uint64_t clientid)
 
enum nfsstat4 nfs41_reclaim_complete (IN nfs41_session *session)
 
static void open_delegation_return (IN nfs41_session *session, IN nfs41_path_fh *file, IN open_delegation4 *delegation, IN bool_t try_recovery)
 
static void open_update_cache (IN nfs41_session *session, IN nfs41_path_fh *parent, IN nfs41_path_fh *file, IN bool_t try_recovery, IN open_delegation4 *delegation, IN bool_t already_delegated, IN change_info4 *changeinfo, IN nfs41_getattr_res *dir_attrs, IN nfs41_getattr_res *file_attrs)
 
int nfs41_open (IN nfs41_session *session, IN nfs41_path_fh *parent, IN nfs41_path_fh *file, IN state_owner4 *owner, IN open_claim4 *claim, IN uint32_t allow, IN uint32_t deny, IN uint32_t create, IN uint32_t how_mode, IN OPTIONAL nfs41_file_info *createattrs, IN bool_t try_recovery, OUT stateid4 *stateid, OUT open_delegation4 *delegation, OUT OPTIONAL nfs41_file_info *info)
 
int nfs41_create (IN nfs41_session *session, IN uint32_t type, IN nfs41_file_info *createattrs, IN OPTIONAL const char *symlink, IN nfs41_path_fh *parent, OUT nfs41_path_fh *file, OUT nfs41_file_info *info)
 
int nfs41_close (IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid_arg *stateid)
 
int nfs41_write (IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid_arg *stateid, IN unsigned char *data, IN uint32_t data_len, IN uint64_t offset, IN enum stable_how4 stable, OUT uint32_t *bytes_written, OUT nfs41_write_verf *verf, OUT nfs41_file_info *cinfo)
 
int nfs41_read (IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid_arg *stateid, IN uint64_t offset, IN uint32_t count, OUT unsigned char *data_out, OUT uint32_t *data_len_out, OUT bool_t *eof_out)
 
int nfs41_commit (IN nfs41_session *session, IN nfs41_path_fh *file, IN uint64_t offset, IN uint32_t count, IN bool_t do_getattr, OUT nfs41_write_verf *verf, OUT nfs41_file_info *cinfo)
 
int nfs41_lock (IN nfs41_session *session, IN nfs41_path_fh *file, IN state_owner4 *owner, IN uint32_t type, IN uint64_t offset, IN uint64_t length, IN bool_t reclaim, IN bool_t try_recovery, IN OUT stateid_arg *stateid)
 
int nfs41_unlock (IN nfs41_session *session, IN nfs41_path_fh *file, IN uint64_t offset, IN uint64_t length, IN OUT stateid_arg *stateid)
 
int nfs41_readdir (IN nfs41_session *session, IN nfs41_path_fh *file, IN bitmap4 *attr_request, IN nfs41_readdir_cookie *cookie, OUT unsigned char *entries, IN OUT uint32_t *entries_len, OUT bool_t *eof_out)
 
int nfs41_getattr (IN nfs41_session *session, IN OPTIONAL nfs41_path_fh *file, IN bitmap4 *attr_request, OUT nfs41_file_info *info)
 
int nfs41_superblock_getattr (IN nfs41_session *session, IN nfs41_path_fh *file, IN bitmap4 *attr_request, OUT nfs41_file_info *info, OUT bool_t *supports_named_attrs)
 
int nfs41_remove (IN nfs41_session *session, IN nfs41_path_fh *parent, IN const nfs41_component *target, IN uint64_t fileid)
 
int nfs41_rename (IN nfs41_session *session, IN nfs41_path_fh *src_dir, IN const nfs41_component *src_name, IN nfs41_path_fh *dst_dir, IN const nfs41_component *dst_name)
 
int nfs41_setattr (IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid_arg *stateid, IN nfs41_file_info *info)
 
int nfs41_link (IN nfs41_session *session, IN nfs41_path_fh *src, IN nfs41_path_fh *dst_dir, IN const nfs41_component *target, OUT nfs41_file_info *cinfo)
 
int nfs41_readlink (IN nfs41_session *session, IN nfs41_path_fh *file, IN uint32_t max_len, OUT char *link_out, OUT uint32_t *len_out)
 
int nfs41_access (IN nfs41_session *session, IN nfs41_path_fh *file, IN uint32_t requested, OUT uint32_t *supported OPTIONAL, OUT uint32_t *access OPTIONAL)
 
int nfs41_send_sequence (IN nfs41_session *session)
 
enum nfsstat4 nfs41_want_delegation (IN nfs41_session *session, IN nfs41_path_fh *file, IN deleg_claim4 *claim, IN uint32_t want, IN bool_t try_recovery, OUT open_delegation4 *delegation)
 
int nfs41_delegpurge (IN nfs41_session *session)
 
int nfs41_delegreturn (IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid_arg *stateid, IN bool_t try_recovery)
 
enum nfsstat4 nfs41_fs_locations (IN nfs41_session *session, IN nfs41_path_fh *parent, IN const nfs41_component *name, OUT fs_locations4 *locations)
 
int nfs41_secinfo (IN nfs41_session *session, IN nfs41_path_fh *file, IN const nfs41_component *name, OUT nfs41_secinfo_info *secinfo)
 
int nfs41_secinfo_noname (IN nfs41_session *session, IN nfs41_path_fh *file, OUT nfs41_secinfo_info *secinfo)
 
enum nfsstat4 nfs41_free_stateid (IN nfs41_session *session, IN stateid4 *stateid)
 
enum nfsstat4 nfs41_test_stateid (IN nfs41_session *session, IN stateid_arg *stateid_array, IN uint32_t count, OUT uint32_t *status_array)
 
enum nfsstat4 pnfs_rpc_layoutget (IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid_arg *stateid, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t minlength, IN uint64_t length, OUT pnfs_layoutget_res_ok *layoutget_res_ok)
 
enum nfsstat4 pnfs_rpc_layoutcommit (IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid4 *stateid, IN uint64_t offset, IN uint64_t length, IN OPTIONAL uint64_t *new_last_offset, IN OPTIONAL nfstime4 *new_time_modify, OUT nfs41_file_info *info)
 
enum nfsstat4 pnfs_rpc_layoutreturn (IN nfs41_session *session, IN nfs41_path_fh *file, IN enum pnfs_layout_type type, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length, IN stateid4 *stateid, OUT pnfs_layoutreturn_res *layoutreturn_res)
 
enum nfsstat4 pnfs_rpc_getdeviceinfo (IN nfs41_session *session, IN unsigned char *deviceid, OUT pnfs_file_device *device)
 
enum nfsstat4 nfs41_rpc_openattr (IN nfs41_session *session, IN nfs41_path_fh *file, IN bool_t createdir, OUT nfs41_fh *fh_out)
 

Function Documentation

◆ nfs41_access()

int nfs41_access ( IN nfs41_session session,
IN nfs41_path_fh file,
IN uint32_t  requested,
OUT uint32_t *supported  OPTIONAL,
OUT uint32_t *access  OPTIONAL 
)

Definition at line 1554 of file nfs41_ops.c.

1560{
1561 int status;
1562 nfs41_compound compound;
1563 nfs_argop4 argops[3];
1564 nfs_resop4 resops[3];
1565 nfs41_sequence_args sequence_args;
1566 nfs41_sequence_res sequence_res;
1567 nfs41_putfh_args putfh_args;
1568 nfs41_putfh_res putfh_res;
1569 nfs41_access_args access_args;
1571
1572 compound_init(&compound, argops, resops, "access");
1573
1574 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1575 nfs41_session_sequence(&sequence_args, session, 0);
1576
1577 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1578 putfh_args.file = file;
1579 putfh_args.in_recovery = 0;
1580
1581 compound_add_op(&compound, OP_ACCESS, &access_args, &access_res);
1582 access_args.access = requested;
1583
1585 if (status)
1586 goto out;
1587
1588 if (compound_error(status = compound.res.status))
1589 goto out;
1590
1591 if (supported)
1592 *supported = access_res.supported;
1593 if (access)
1594 *access = access_res.access;
1595out:
1596 return status;
1597}
#define TRUE
Definition: types.h:120
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
void nfs41_session_sequence(struct __nfs41_sequence_args *args, nfs41_session *session, bool_t cachethis)
void compound_init(nfs41_compound *compound, nfs_argop4 *argops, nfs_resop4 *resops, const char *tag)
int compound_encode_send_decode(nfs41_session *session, nfs41_compound *compound, bool_t try_recovery)
void compound_add_op(nfs41_compound *compound, uint32_t opnum, void *arg, void *res)
int compound_error(int status)
@ OP_ACCESS
Definition: nfs41_ops.h:31
@ OP_SEQUENCE
Definition: nfs41_ops.h:83
@ OP_PUTFH
Definition: nfs41_ops.h:50
static FILE * out
Definition: regtests2xml.c:44
nfs41_compound_res res
nfs41_path_fh * file
Definition: nfs41_ops.h:510
Definition: fci.c:127
Definition: ps.c:97

Referenced by check_execute_access().

◆ nfs41_bind_conn_to_session()

enum nfsstat4 nfs41_bind_conn_to_session ( IN nfs41_rpc_clnt rpc,
IN const unsigned char sessionid,
IN enum channel_dir_from_client4  dir 
)

Definition at line 185 of file nfs41_ops.c.

189{
190 int status;
191 nfs41_compound compound;
192 nfs_argop4 argop;
193 nfs_resop4 resop;
194 nfs41_bind_conn_to_session_args bind_args = { 0 };
195 nfs41_bind_conn_to_session_res bind_res = { 0 };
196
197 compound_init(&compound, &argop, &resop, "bind_conn_to_session");
198
199 compound_add_op(&compound, OP_BIND_CONN_TO_SESSION, &bind_args, &bind_res);
200 bind_args.sessionid = (unsigned char *)sessionid;
201 bind_args.dir = dir;
202
204 (char*)&compound.args, (char*)&compound.res);
205 if (status)
206 goto out;
207
208 compound_error(status = compound.res.status);
209
210out:
211 return status;
212}
unsigned int dir
Definition: maze.c:112
int nfs41_send_compound(IN nfs41_rpc_clnt *rpc, IN char *inbuf, OUT char *outbuf)
Definition: nfs41_rpc.c:337
@ OP_BIND_CONN_TO_SESSION
Definition: nfs41_ops.h:71
enum channel_dir_from_client4 dir
Definition: nfs41_ops.h:197
nfs41_compound_args args

Referenced by compound_encode_send_decode(), and rpc_reconnect().

◆ nfs41_close()

int nfs41_close ( IN nfs41_session session,
IN nfs41_path_fh file,
IN stateid_arg stateid 
)

Definition at line 627 of file nfs41_ops.c.

631{
632 int status;
633 nfs41_compound compound;
634 nfs_argop4 argops[4];
635 nfs_resop4 resops[4];
636 nfs41_sequence_args sequence_args;
637 nfs41_sequence_res sequence_res;
638 nfs41_putfh_args putfh_args;
639 nfs41_putfh_res putfh_res;
640 nfs41_op_close_args close_args;
641 nfs41_op_close_res close_res;
642 nfs41_getattr_args getattr_args;
643 nfs41_getattr_res getattr_res;
644 bitmap4 attr_request;
646
647 nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
648
649 compound_init(&compound, argops, resops, "close");
650
651 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
652 nfs41_session_sequence(&sequence_args, session, 1);
653
654 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
655 putfh_args.file = file;
656 putfh_args.in_recovery = 0;
657
658 compound_add_op(&compound, OP_CLOSE, &close_args, &close_res);
659 close_args.stateid = stateid;
660
661 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
662 getattr_args.attr_request = &attr_request;
664 getattr_res.info = &info;
665
667 if (status)
668 goto out;
669
670 if (compound_error(status = compound.res.status))
671 goto out;
672
673 if (info.type == NF4NAMEDATTR)
674 goto out;
675
676 /* update the attributes of the parent directory */
677 memcpy(&info.attrmask, &getattr_res.obj_attributes.attrmask,
678 sizeof(bitmap4));
680 file->fh.fileid, &info);
681out:
682 return status;
683}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
int nfs41_attr_cache_update(IN struct nfs41_name_cache *cache, IN uint64_t fileid, IN const nfs41_file_info *info)
Definition: name_cache.c:891
static __inline struct nfs41_name_cache * session_name_cache(IN nfs41_session *session)
Definition: name_cache.h:34
static __inline void nfs41_superblock_getattr_mask(IN const nfs41_superblock *superblock, OUT bitmap4 *attrs)
Definition: nfs41.h:448
@ NF4NAMEDATTR
Definition: nfs41_const.h:302
#define NFS4_OPAQUE_LIMIT
Definition: nfs41_const.h:31
@ OP_CLOSE
Definition: nfs41_ops.h:32
@ OP_GETATTR
Definition: nfs41_ops.h:37
uint32_t attr_vals_len
Definition: nfs41_types.h:161
bitmap4 attrmask
Definition: nfs41_types.h:160
bitmap4 * attr_request
Definition: nfs41_ops.h:527
nfs41_file_info * info
Definition: nfs41_ops.h:534
stateid_arg * stateid
Definition: nfs41_ops.h:316

Referenced by cancel_open(), do_nfs41_close(), get_ea_value(), recover_delegation_open(), and set_ea_value().

◆ nfs41_commit()

int nfs41_commit ( IN nfs41_session session,
IN nfs41_path_fh file,
IN uint64_t  offset,
IN uint32_t  count,
IN bool_t  do_getattr,
OUT nfs41_write_verf verf,
OUT nfs41_file_info cinfo 
)

Definition at line 833 of file nfs41_ops.c.

841{
842 int status;
843 nfs41_compound compound;
844 nfs_argop4 argops[4];
845 nfs_resop4 resops[4];
846 nfs41_sequence_args sequence_args;
847 nfs41_sequence_res sequence_res;
848 nfs41_putfh_args putfh_args;
849 nfs41_putfh_res putfh_res;
850 nfs41_commit_args commit_args;
851 nfs41_commit_res commit_res;
852 nfs41_getattr_args getattr_args;
853 nfs41_getattr_res getattr_res = {0};
854 bitmap4 attr_request;
855 nfs41_file_info info, *pinfo;
856
857 compound_init(&compound, argops, resops,
858 do_getattr ? "commit" : "ds commit");
859
860 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
861 nfs41_session_sequence(&sequence_args, session, 1);
862
863 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
864 putfh_args.file = file;
865 putfh_args.in_recovery = 0;
866
867 compound_add_op(&compound, OP_COMMIT, &commit_args, &commit_res);
868 commit_args.offset = offset;
869 commit_args.count = count;
870 commit_res.verf = verf;
871
872 /* send a GETATTR request to update the attribute cache,
873 * but not if we're talking to a data server! */
874 if (cinfo) pinfo = cinfo;
875 else pinfo = &info;
876 if (do_getattr) {
877 nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
878
879 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
880 getattr_args.attr_request = &attr_request;
882 getattr_res.info = pinfo;
883 }
884
886 if (status)
887 goto out;
888
889 if (compound_error(status = compound.res.status))
890 goto out;
891
892 if (do_getattr) {
893 /* update the attribute cache */
894 memcpy(&pinfo->attrmask, &getattr_res.obj_attributes.attrmask,
895 sizeof(bitmap4));
897 file->fh.fileid, pinfo);
898 }
899 nfs41_superblock_space_changed(file->fh.superblock);
900out:
901 return status;
902}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLintptr offset
Definition: glext.h:5920
void nfs41_superblock_space_changed(IN nfs41_superblock *superblock)
@ OP_COMMIT
Definition: nfs41_ops.h:33
nfs41_write_verf * verf
Definition: nfs41_ops.h:332

Referenced by file_layout_write_thread(), mds_commit(), and write_to_mds().

◆ nfs41_create()

int nfs41_create ( IN nfs41_session session,
IN uint32_t  type,
IN nfs41_file_info createattrs,
IN OPTIONAL const char symlink,
IN nfs41_path_fh parent,
OUT nfs41_path_fh file,
OUT nfs41_file_info info 
)

Definition at line 530 of file nfs41_ops.c.

538{
539 int status;
540 nfs41_compound compound;
541 nfs_argop4 argops[8];
542 nfs_resop4 resops[8];
543 nfs41_sequence_args sequence_args;
544 nfs41_sequence_res sequence_res;
545 nfs41_putfh_args putfh_args;
546 nfs41_putfh_res putfh_res;
547 nfs41_create_args create_args;
548 nfs41_create_res create_res;
549 nfs41_getfh_res getfh_res;
550 nfs41_getattr_args getattr_args;
551 nfs41_getattr_res getattr_res, pgetattr_res;
552 bitmap4 attr_request;
553 nfs41_file_info dir_info;
554 nfs41_savefh_res savefh_res;
555 nfs41_restorefh_res restorefh_res;
556
557 nfs41_superblock_getattr_mask(parent->fh.superblock, &attr_request);
558
559 compound_init(&compound, argops, resops, "create");
560
561 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
562 nfs41_session_sequence(&sequence_args, session, 1);
563
564 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
565 putfh_args.file = parent;
566 putfh_args.in_recovery = 0;
567
568 compound_add_op(&compound, OP_SAVEFH, NULL, &savefh_res);
569
570 compound_add_op(&compound, OP_CREATE, &create_args, &create_res);
571 create_args.objtype.type = type;
572 if (type == NF4LNK) {
573 create_args.objtype.u.lnk.linkdata = symlink;
574 create_args.objtype.u.lnk.linkdata_len = (uint32_t)strlen(symlink);
575 }
576 create_args.name = &file->name;
577 create_args.createattrs = createattrs;
579 parent->fh.superblock, &createattrs->attrmask);
580
581 compound_add_op(&compound, OP_GETFH, NULL, &getfh_res);
582 getfh_res.fh = &file->fh;
583
584 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
585 getattr_args.attr_request = &attr_request;
587 getattr_res.info = info;
588
589 compound_add_op(&compound, OP_RESTOREFH, NULL, &restorefh_res);
590
591 compound_add_op(&compound, OP_GETATTR, &getattr_args, &pgetattr_res);
592 getattr_args.attr_request = &attr_request;
594 pgetattr_res.info = &dir_info;
595
597 if (status)
598 goto out;
599
600 if (compound_error(status = compound.res.status))
601 goto out;
602
603 /* fill in the file handle's fileid and superblock */
604 file->fh.fileid = info->fileid;
605 file->fh.superblock = parent->fh.superblock;
606
607 /* update the attributes of the parent directory */
608 memcpy(&dir_info.attrmask, &pgetattr_res.obj_attributes.attrmask,
609 sizeof(bitmap4));
611 parent->fh.fileid, &dir_info);
612
613 /* add the new file handle and attributes to the name cache */
614 memcpy(&info->attrmask, &getattr_res.obj_attributes.attrmask,
615 sizeof(bitmap4));
618 file->path->path, &file->name, &file->fh,
619 info, &create_res.cinfo, OPEN_DELEGATE_NONE);
621
622 nfs41_superblock_space_changed(file->fh.superblock);
623out:
624 return status;
625}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define NULL
Definition: types.h:112
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
r parent
Definition: btrfs.c:3010
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int nfs41_name_cache_insert(IN struct nfs41_name_cache *cache, IN const char *path, IN const nfs41_component *name, IN OPTIONAL const nfs41_fh *fh, IN OPTIONAL const nfs41_file_info *info, IN OPTIONAL const change_info4 *cinfo, IN enum open_delegation_type4 delegation)
Definition: name_cache.c:923
static __inline void nfs41_superblock_supported_attrs(IN const nfs41_superblock *superblock, IN OUT bitmap4 *attrs)
Definition: nfs41.h:454
@ NF4LNK
Definition: nfs41_const.h:298
@ OPEN_DELEGATE_NONE
Definition: nfs41_ops.h:586
@ OP_RESTOREFH
Definition: nfs41_ops.h:59
@ OP_GETFH
Definition: nfs41_ops.h:38
@ OP_SAVEFH
Definition: nfs41_ops.h:60
@ OP_CREATE
Definition: nfs41_ops.h:34
#define uint32_t
Definition: nsiface.idl:61
union __createtype4::@38 u
struct __createtype4::@38::__create_type_lnk lnk
uint32_t type
Definition: nfs41_ops.h:343
createtype4 objtype
Definition: nfs41_ops.h:356
const nfs41_component * name
Definition: nfs41_ops.h:357
nfs41_file_info * createattrs
Definition: nfs41_ops.h:358
change_info4 cinfo
Definition: nfs41_ops.h:364
nfs41_fh * fh
Definition: nfs41_ops.h:504
WCHAR * path
Definition: filesystem.c:122
char name[1]
Definition: fci.c:135

Referenced by handle_open(), and handle_symlink().

◆ nfs41_create_session()

int nfs41_create_session ( nfs41_client clnt,
nfs41_session session,
bool_t  try_recovery 
)

Definition at line 101 of file nfs41_ops.c.

102{
103 int status = 0;
104 nfs41_compound compound;
105 nfs_argop4 argop;
106 nfs_resop4 resop;
107 nfs41_create_session_args req = { 0 };
108 nfs41_create_session_res reply = { 0 };
109
110 compound_init(&compound, &argop, &resop, "create_session");
111
112 compound_add_op(&compound, OP_CREATE_SESSION, &req, &reply);
113
115 req.csa_clientid = clnt->clnt_id;
116 req.csa_sequence = clnt->seq_id;
118 req.csa_flags = session->flags;
120 req.csa_cb_secparams[0].type = 0; /* AUTH_NONE */
121 req.csa_cb_secparams[1].type = 1; /* AUTH_SYS */
122 req.csa_cb_secparams[1].u.auth_sys.machinename = clnt->rpc->server_name;
123 req.csa_cb_secparams[1].u.auth_sys.stamp = (uint32_t)time(NULL);
124
125 // ca_maxrequests should be gotten from the rpc layer
129 1, &req.csa_back_chan_attrs);
130
131 reply.csr_sessionid = session->session_id;
132 reply.csr_fore_chan_attrs = &session->fore_chan_attrs;
133 reply.csr_back_chan_attrs = &session->back_chan_attrs;
134
135 status = compound_encode_send_decode(session, &compound, try_recovery);
136 if (status)
137 goto out;
138
139 if (compound_error(status = compound.res.status))
140 goto out;
141
142 print_hexbuf(1, (unsigned char *)"session id: ", session->session_id, NFS4_SESSIONID_SIZE);
143 // check that csa_sequence is same as csr_sequence
144 if (reply.csr_sequence != clnt->seq_id) {
145 eprintf("ERROR: CREATE_SESSION: csa_sequence %d != "
146 "csr_sequence %d\n", clnt->seq_id, reply.csr_sequence);
148 goto out;
149 } else clnt->seq_id++;
150
151 if (reply.csr_flags != req.csa_flags) {
152 eprintf("WARNING: requested session flags %x received %x\n",
153 req.csa_flags, reply.csr_flags);
156 eprintf("WARNING: we asked to use this session for callbacks but "
157 "server refused\n");
158 if ((session->flags & CREATE_SESSION4_FLAG_PERSIST) &&
160 eprintf("WARNING: we asked for persistent session but "
161 "server refused\n");
162 session->flags = reply.csr_flags;
163 }
164 else
165 dprintf(1, "session flags %x\n", reply.csr_flags);
166
167 dprintf(1, "session fore_chan_attrs:\n"
168 " %-32s%d\n %-32s%d\n %-32s%d\n %-32s%d\n %-32s%d\n %-32s%d\n",
169 "headerpadsize", session->fore_chan_attrs.ca_headerpadsize,
170 "maxrequestsize", session->fore_chan_attrs.ca_maxrequestsize,
171 "maxresponsesize", session->fore_chan_attrs.ca_maxresponsesize,
172 "maxresponsesize_cached", session->fore_chan_attrs.ca_maxresponsesize_cached,
173 "maxoperations", session->fore_chan_attrs.ca_maxoperations,
174 "maxrequests", session->fore_chan_attrs.ca_maxrequests);
175 dprintf(1, "client supports %d max rpc slots, but server has %d\n",
176 session->table.max_slots, session->fore_chan_attrs.ca_maxrequests);
177 /* use the server's ca_maxrequests unless it's bigger than our array */
178 session->table.max_slots = min(session->table.max_slots,
179 session->fore_chan_attrs.ca_maxrequests);
180 status = 0;
181out:
182 return status;
183}
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
void print_hexbuf(int level, unsigned char *title, unsigned char *buf, int len)
Definition: daemon_debug.c:98
__u16 time
Definition: mkdosfs.c:8
#define min(a, b)
Definition: monoChain.cc:55
#define NFS41_RPC_CBPROGRAM
Definition: nfs41_const.h:80
#define CREATE_SESSION4_FLAG_PERSIST
Definition: nfs41_const.h:307
#define NFS4_SESSIONID_SIZE
Definition: nfs41_const.h:32
@ NFS4ERR_SEQ_MISORDERED
Definition: nfs41_const.h:172
#define CREATE_SESSION4_FLAG_CONN_BACK_CHAN
Definition: nfs41_const.h:308
#define NFS41_MAX_RPC_REQS
Definition: nfs41_const.h:40
static int set_back_channel_attrs(IN nfs41_rpc_clnt *rpc, IN uint32_t max_req, OUT nfs41_channel_attrs *attrs)
Definition: nfs41_ops.c:86
static int set_fore_channel_attrs(IN nfs41_rpc_clnt *rpc, IN uint32_t max_req, OUT nfs41_channel_attrs *attrs)
Definition: nfs41_ops.c:70
@ OP_CREATE_SESSION
Definition: nfs41_ops.h:73
#define dprintf
Definition: regdump.c:33
struct __nfs41_callback_sec_parms::@37::__authsys_parms auth_sys
union __nfs41_callback_sec_parms::@37 u
nfs41_rpc_clnt * rpc
Definition: nfs41.h:201
uint64_t clnt_id
Definition: nfs41.h:195
SRWLOCK exid_lock
Definition: nfs41.h:198
uint32_t seq_id
Definition: nfs41.h:196
nfs41_channel_attrs csa_back_chan_attrs
Definition: nfs41_ops.h:167
nfs41_callback_secparms csa_cb_secparams[2]
Definition: nfs41_ops.h:169
nfs41_channel_attrs csa_fore_chan_attrs
Definition: nfs41_ops.h:166
nfs41_channel_attrs * csr_back_chan_attrs
Definition: nfs41_ops.h:177
nfs41_channel_attrs * csr_fore_chan_attrs
Definition: nfs41_ops.h:176
unsigned char * csr_sessionid
Definition: nfs41_ops.h:173
char server_name[NI_MAXHOST]
Definition: nfs41.h:180

Referenced by nfs41_session_create(), and nfs41_session_renew().

◆ nfs41_delegpurge()

int nfs41_delegpurge ( IN nfs41_session session)

Definition at line 1666 of file nfs41_ops.c.

1668{
1669 int status;
1670 nfs41_compound compound;
1671 nfs_argop4 argops[2];
1672 nfs_resop4 resops[2];
1673 nfs41_sequence_args sequence_args;
1674 nfs41_sequence_res sequence_res;
1675 nfs41_delegpurge_res dp_res;
1676
1677 compound_init(&compound, argops, resops, "delegpurge");
1678
1679 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1680 nfs41_session_sequence(&sequence_args, session, 0);
1681
1682 compound_add_op(&compound, OP_DELEGPURGE, NULL, &dp_res);
1683
1685 if (status)
1686 goto out;
1687
1688 compound_error(status = compound.res.status);
1689out:
1690 return status;
1691}
@ OP_DELEGPURGE
Definition: nfs41_ops.h:35

Referenced by nfs41_client_delegation_recovery().

◆ nfs41_delegreturn()

int nfs41_delegreturn ( IN nfs41_session session,
IN nfs41_path_fh file,
IN stateid_arg stateid,
IN bool_t  try_recovery 
)

Definition at line 1693 of file nfs41_ops.c.

1698{
1699 int status;
1700 nfs41_compound compound;
1701 nfs_argop4 argops[3];
1702 nfs_resop4 resops[3];
1703 nfs41_sequence_args sequence_args;
1704 nfs41_sequence_res sequence_res;
1705 nfs41_putfh_args putfh_args;
1706 nfs41_putfh_res putfh_res;
1707 nfs41_delegreturn_args dr_args;
1708 nfs41_delegreturn_res dr_res;
1709
1710 compound_init(&compound, argops, resops, "delegreturn");
1711
1712 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1713 nfs41_session_sequence(&sequence_args, session, 0);
1714
1715 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1716 putfh_args.file = file;
1717 putfh_args.in_recovery = 0;
1718
1719 compound_add_op(&compound, OP_DELEGRETURN, &dr_args, &dr_res);
1720 dr_args.stateid = stateid;
1721
1722 status = compound_encode_send_decode(session, &compound, try_recovery);
1723 if (status)
1724 goto out;
1725
1726 if (compound_error(status = compound.res.status))
1727 goto out;
1728
1731 file->fh.fileid, file->path->path, &file->name);
1733out:
1734 return status;
1735}
int nfs41_name_cache_delegreturn(IN struct nfs41_name_cache *cache, IN uint64_t fileid, IN const char *path, IN const nfs41_component *name)
Definition: name_cache.c:1012
@ OP_DELEGRETURN
Definition: nfs41_ops.h:36
stateid_arg * stateid
Definition: nfs41_ops.h:377

Referenced by delegation_return(), nfs41_delegation_granted(), and open_delegation_return().

◆ nfs41_destroy_clientid()

int nfs41_destroy_clientid ( IN nfs41_rpc_clnt rpc,
IN uint64_t  clientid 
)

Definition at line 242 of file nfs41_ops.c.

245{
246 int status;
247 nfs41_compound compound;
248 nfs_argop4 argops;
249 nfs_resop4 resops;
252
253 compound_init(&compound, &argops, &resops, "destroy_clientid");
254
255 compound_add_op(&compound, OP_DESTROY_CLIENTID, &dc_args, &dc_res);
256 dc_args.dca_clientid = clientid;
257
258 status = nfs41_send_compound(rpc, (char *)&compound.args,
259 (char *)&compound.res);
260 if (status)
261 goto out;
262
263 compound_error(status = compound.res.status);
264out:
265 return status;
266}
@ OP_DESTROY_CLIENTID
Definition: nfs41_ops.h:87

Referenced by nfs41_client_free().

◆ nfs41_destroy_session()

int nfs41_destroy_session ( IN nfs41_session session)

Definition at line 214 of file nfs41_ops.c.

216{
217 int status;
218 nfs41_compound compound;
219 nfs_argop4 argop;
220 nfs_resop4 resop;
223
224 compound_init(&compound, &argop, &resop, "destroy_session");
225
226 compound_add_op(&compound, OP_DESTROY_SESSION, &ds_args, &ds_res);
227 ds_args.dsa_sessionid = session->session_id;
228
229 /* don't attempt to recover from BADSESSION/STALE_CLIENTID */
231 if (status)
232 goto out;
233
234 status = compound.res.status;
235 if (status)
236 eprintf("%s failed with status %d.\n",
238out:
239 return status;
240}
const char * nfs_opnum_to_string(int opnum)
Definition: daemon_debug.c:305
#define FALSE
Definition: types.h:117
@ OP_DESTROY_SESSION
Definition: nfs41_ops.h:74
unsigned char * dsa_sessionid
Definition: nfs41_ops.h:209

Referenced by nfs41_session_free().

◆ nfs41_exchange_id()

int nfs41_exchange_id ( IN nfs41_rpc_clnt rpc,
IN client_owner4 owner,
IN uint32_t  flags_in,
OUT nfs41_exchange_id_res res_out 
)

Definition at line 36 of file nfs41_ops.c.

41{
42 int status = 0;
43 nfs41_compound compound;
44 nfs_argop4 argop;
45 nfs_resop4 resop;
47
48 compound_init(&compound, &argop, &resop, "exchange_id");
49
50 compound_add_op(&compound, OP_EXCHANGE_ID, &ex_id, res_out);
51 ex_id.eia_clientowner = owner;
52 ex_id.eia_flags = flags_in;
55
56 res_out->server_owner.so_major_id_len = NFS4_OPAQUE_LIMIT;
57 res_out->server_scope_len = NFS4_OPAQUE_LIMIT;
58
59 status = nfs41_send_compound(rpc, (char *)&compound.args,
60 (char *)&compound.res);
61 if (status)
62 goto out;
63
64 compound_error(status = compound.res.status);
65out:
66 return status;
67}
@ SP4_NONE
Definition: nfs41_ops.h:111
@ OP_EXCHANGE_ID
Definition: nfs41_ops.h:72
client_owner4 * eia_clientowner
Definition: nfs41_ops.h:121
nfs_impl_id4 * eia_client_impl_id
Definition: nfs41_ops.h:124
state_protect4_a eia_state_protect
Definition: nfs41_ops.h:123
state_protect_how4 spa_how
Definition: nfs41_ops.h:117

Referenced by nfs41_client_renew(), and nfs41_root_mount_addrs().

◆ nfs41_free_stateid()

enum nfsstat4 nfs41_free_stateid ( IN nfs41_session session,
IN stateid4 stateid 
)

Definition at line 1870 of file nfs41_ops.c.

1873{
1874 enum nfsstat4 status;
1875 nfs41_compound compound;
1876 nfs_argop4 argops[2];
1877 nfs_resop4 resops[2];
1878 nfs41_sequence_args sequence_args;
1879 nfs41_sequence_res sequence_res;
1880 nfs41_free_stateid_args freestateid_args;
1881 nfs41_free_stateid_res freestateid_res;
1882
1883 compound_init(&compound, argops, resops, "free_stateid");
1884
1885 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1886 nfs41_session_sequence(&sequence_args, session, 0);
1887
1888 compound_add_op(&compound, OP_FREE_STATEID, &freestateid_args, &freestateid_res);
1889 freestateid_args.stateid = stateid;
1890
1892 if (status)
1893 goto out;
1894
1895 compound_error(status = compound.res.status);
1896out:
1897 return status;
1898}
nfsstat4
Definition: nfs41_const.h:86
@ OP_FREE_STATEID
Definition: nfs41_ops.h:75

Referenced by nfs41_client_state_revoked().

◆ nfs41_fs_locations()

enum nfsstat4 nfs41_fs_locations ( IN nfs41_session session,
IN nfs41_path_fh parent,
IN const nfs41_component name,
OUT fs_locations4 locations 
)

Definition at line 1737 of file nfs41_ops.c.

1742{
1743 enum nfsstat4 status;
1744 nfs41_compound compound;
1745 nfs_argop4 argops[4];
1746 nfs_resop4 resops[4];
1747 nfs41_sequence_args sequence_args;
1748 nfs41_sequence_res sequence_res;
1749 nfs41_putfh_args putfh_args;
1750 nfs41_putfh_res putfh_res;
1751 nfs41_lookup_args lookup_args;
1752 nfs41_lookup_res lookup_res;
1753 nfs41_getattr_args getattr_args;
1754 nfs41_getattr_res getattr_res;
1755 bitmap4 attr_request = { 1, { FATTR4_WORD0_FS_LOCATIONS } };
1757
1758 compound_init(&compound, argops, resops, "fs_locations");
1759
1760 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1761 nfs41_session_sequence(&sequence_args, session, 0);
1762
1763 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1764 putfh_args.file = parent;
1765 putfh_args.in_recovery = 0;
1766
1767 compound_add_op(&compound, OP_LOOKUP, &lookup_args, &lookup_res);
1768 lookup_args.name = name;
1769
1770 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
1771 getattr_args.attr_request = &attr_request;
1772 info.fs_locations = locations;
1774 getattr_res.info = &info;
1775
1777 if (status)
1778 goto out;
1779
1780 compound_error(status = compound.res.status);
1781out:
1782 return status;
1783}
GLsizei const GLint * locations
Definition: glext.h:10542
@ FATTR4_WORD0_FS_LOCATIONS
Definition: nfs41_const.h:236
@ OP_LOOKUP
Definition: nfs41_ops.h:43
const nfs41_component * name
Definition: nfs41_ops.h:492
Definition: name.c:39

Referenced by referral_resolve().

◆ nfs41_getattr()

int nfs41_getattr ( IN nfs41_session session,
IN OPTIONAL nfs41_path_fh file,
IN bitmap4 attr_request,
OUT nfs41_file_info info 
)

Definition at line 1063 of file nfs41_ops.c.

1068{
1069 int status;
1070 nfs41_compound compound;
1071 nfs_argop4 argops[3];
1072 nfs_resop4 resops[3];
1073 nfs41_sequence_args sequence_args;
1074 nfs41_sequence_res sequence_res;
1075 nfs41_putfh_args putfh_args;
1076 nfs41_putfh_res putfh_res;
1077 nfs41_getattr_args getattr_args;
1078 nfs41_getattr_res getattr_res;
1079
1080 compound_init(&compound, argops, resops, "getattr");
1081
1082 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1083 nfs41_session_sequence(&sequence_args, session, 0);
1084
1085 if (file) {
1086 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1087 putfh_args.file = file;
1088 putfh_args.in_recovery = 0;
1089 } else {
1090 compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
1091 }
1092
1093 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
1094 getattr_args.attr_request = attr_request;
1096 getattr_res.info = info;
1097
1099 if (status)
1100 goto out;
1101
1102 if (compound_error(status = compound.res.status))
1103 goto out;
1104
1105 if (file) {
1106 /* update the name cache with whatever attributes we got */
1107 memcpy(&info->attrmask, &getattr_res.obj_attributes.attrmask,
1108 sizeof(bitmap4));
1110 file->fh.fileid, info);
1111 }
1112out:
1113 return status;
1114}
@ OP_PUTROOTFH
Definition: nfs41_ops.h:52

Referenced by get_volume_size_info(), handle_getacl(), nfs41_cached_getattr(), pnfs_write(), session_get_lease(), and write_to_mds().

◆ nfs41_link()

int nfs41_link ( IN nfs41_session session,
IN nfs41_path_fh src,
IN nfs41_path_fh dst_dir,
IN const nfs41_component target,
OUT nfs41_file_info cinfo 
)

Definition at line 1407 of file nfs41_ops.c.

1413{
1414 int status;
1415 nfs41_compound compound;
1416 nfs_argop4 argops[9];
1417 nfs_resop4 resops[9];
1418 nfs41_sequence_args sequence_args;
1419 nfs41_sequence_res sequence_res;
1420 nfs41_putfh_args putfh_args[2];
1421 nfs41_putfh_res putfh_res[2];
1422 nfs41_savefh_res savefh_res;
1423 nfs41_link_args link_args;
1424 nfs41_link_res link_res;
1425 nfs41_lookup_args lookup_args;
1426 nfs41_lookup_res lookup_res;
1427 nfs41_getfh_res getfh_res;
1428 nfs41_getattr_args getattr_args[2];
1429 nfs41_getattr_res getattr_res[2];
1430 nfs41_file_info info = { 0 };
1432
1433 nfs41_superblock_getattr_mask(src->fh.superblock, &info.attrmask);
1434 nfs41_superblock_getattr_mask(dst_dir->fh.superblock, &cinfo->attrmask);
1435 cinfo->attrmask.arr[0] |= FATTR4_WORD0_FSID;
1436
1437 compound_init(&compound, argops, resops, "link");
1438
1439 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1440 nfs41_session_sequence(&sequence_args, session, 1);
1441
1442 /* PUTFH(src) */
1443 compound_add_op(&compound, OP_PUTFH, &putfh_args[0], &putfh_res[0]);
1444 putfh_args[0].file = src;
1445 putfh_args[0].in_recovery = 0;
1446
1447 compound_add_op(&compound, OP_SAVEFH, NULL, &savefh_res);
1448
1449 /* PUTFH(dst_dir) */
1450 compound_add_op(&compound, OP_PUTFH, &putfh_args[1], &putfh_res[1]);
1451 putfh_args[1].file = dst_dir;
1452 putfh_args[1].in_recovery = 0;
1453
1454 compound_add_op(&compound, OP_LINK, &link_args, &link_res);
1455 link_args.newname = target;
1456
1457 /* GETATTR(dst_dir) */
1458 compound_add_op(&compound, OP_GETATTR, &getattr_args[0], &getattr_res[0]);
1459 getattr_args[0].attr_request = &info.attrmask;
1461 getattr_res[0].info = &info;
1462
1463 /* LOOKUP(target) */
1464 compound_add_op(&compound, OP_LOOKUP, &lookup_args, &lookup_res);
1465 lookup_args.name = target;
1466
1467 /* GETATTR(target) */
1468 compound_add_op(&compound, OP_GETATTR, &getattr_args[1], &getattr_res[1]);
1469 getattr_args[1].attr_request = &cinfo->attrmask;
1471 getattr_res[1].info = cinfo;
1472
1473 /* GETFH(target) */
1474 compound_add_op(&compound, OP_GETFH, NULL, &getfh_res);
1475 getfh_res.fh = &file.fh;
1476
1478 if (status)
1479 goto out;
1480
1481 if (compound_error(status = compound.res.status))
1482 goto out;
1483
1484 /* fill in the file handle's fileid and superblock */
1485 file.fh.fileid = cinfo->fileid;
1487 &cinfo->fsid, &dst_dir->fh, &file);
1488 if (status)
1489 goto out;
1490
1491 /* update the attributes of the destination directory */
1492 memcpy(&info.attrmask, &getattr_res[0].obj_attributes.attrmask,
1493 sizeof(bitmap4));
1495 info.fileid, &info);
1496
1497 /* add the new file handle and attributes to the name cache */
1498 memcpy(&cinfo->attrmask, &getattr_res[1].obj_attributes.attrmask,
1499 sizeof(bitmap4));
1500 AcquireSRWLockShared(&dst_dir->path->lock);
1502 dst_dir->path->path, target, &file.fh,
1503 cinfo, &link_res.cinfo, OPEN_DELEGATE_NONE);
1504 ReleaseSRWLockShared(&dst_dir->path->lock);
1505
1506 nfs41_superblock_space_changed(dst_dir->fh.superblock);
1507out:
1508 return status;
1509}
GLenum src
Definition: glext.h:6340
GLenum target
Definition: glext.h:7315
int nfs41_superblock_for_fh(IN nfs41_session *session, IN const nfs41_fsid *fsid, IN const nfs41_fh *parent OPTIONAL, OUT nfs41_path_fh *file)
@ FATTR4_WORD0_FSID
Definition: nfs41_const.h:215
@ OP_LINK
Definition: nfs41_ops.h:39

◆ nfs41_lock()

int nfs41_lock ( IN nfs41_session session,
IN nfs41_path_fh file,
IN state_owner4 owner,
IN uint32_t  type,
IN uint64_t  offset,
IN uint64_t  length,
IN bool_t  reclaim,
IN bool_t  try_recovery,
IN OUT stateid_arg stateid 
)

Definition at line 904 of file nfs41_ops.c.

914{
915 int status;
916 nfs41_compound compound;
917 nfs_argop4 argops[3];
918 nfs_resop4 resops[3];
919 nfs41_sequence_args sequence_args;
920 nfs41_sequence_res sequence_res;
921 nfs41_putfh_args putfh_args;
922 nfs41_putfh_res putfh_res;
923 nfs41_lock_args lock_args;
924 nfs41_lock_res lock_res;
925
926 compound_init(&compound, argops, resops, "lock");
927
928 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
929 nfs41_session_sequence(&sequence_args, session, 0);
930
931 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
932 putfh_args.file = file;
933 putfh_args.in_recovery = 0;
934
935 compound_add_op(&compound, OP_LOCK, &lock_args, &lock_res);
936 lock_args.locktype = type;
937 lock_args.reclaim = reclaim;
938 lock_args.offset = offset;
939 lock_args.length = length;
940 if (stateid->type == STATEID_LOCK) {
941 lock_args.locker.new_lock_owner = 0;
942 lock_args.locker.u.lock_owner.lock_stateid = stateid;
943 lock_args.locker.u.lock_owner.lock_seqid = 0; /* ignored */
944 } else {
945 lock_args.locker.new_lock_owner = 1;
946 lock_args.locker.u.open_owner.open_seqid = 0; /* ignored */
947 lock_args.locker.u.open_owner.open_stateid = stateid;
948 lock_args.locker.u.open_owner.lock_seqid = 0; /* ignored */
949 lock_args.locker.u.open_owner.lock_owner = owner;
950 }
951 lock_res.u.resok4.lock_stateid = &stateid->stateid;
953
954 status = compound_encode_send_decode(session, &compound, try_recovery);
955 if (status)
956 goto out;
957
958 if (compound_error(status = compound.res.status))
959 goto out;
960
961 stateid->type = STATEID_LOCK; /* returning a lock stateid */
962out:
963 return status;
964}
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
@ OP_LOCK
Definition: nfs41_ops.h:40
@ STATEID_LOCK
Definition: nfs41_ops.h:277
stateid_arg * lock_stateid
Definition: nfs41_ops.h:413
uint32_t lock_seqid
Definition: nfs41_ops.h:414
state_owner4 owner
Definition: nfs41_ops.h:439
stateid4 * lock_stateid
Definition: nfs41_ops.h:443
open_to_lock_owner4 open_owner
Definition: nfs41_ops.h:421
bool_t new_lock_owner
Definition: nfs41_ops.h:418
exist_lock_owner4 lock_owner
Definition: nfs41_ops.h:423
union __locker4::@39 u
uint64_t length
Definition: nfs41_ops.h:431
uint32_t locktype
Definition: nfs41_ops.h:428
uint64_t offset
Definition: nfs41_ops.h:430
union __nfs41_lock_res::@40 u
lock_res_denied denied
Definition: nfs41_ops.h:452
lock_res_ok resok4
Definition: nfs41_ops.h:450
state_owner4 * lock_owner
Definition: nfs41_ops.h:409
stateid_arg * open_stateid
Definition: nfs41_ops.h:407
uint32_t owner_len
Definition: nfs41_types.h:118

Referenced by delegation_flush_locks(), handle_lock(), and recover_locks().

◆ nfs41_open()

int nfs41_open ( IN nfs41_session session,
IN nfs41_path_fh parent,
IN nfs41_path_fh file,
IN state_owner4 owner,
IN open_claim4 claim,
IN uint32_t  allow,
IN uint32_t  deny,
IN uint32_t  create,
IN uint32_t  how_mode,
IN OPTIONAL nfs41_file_info createattrs,
IN bool_t  try_recovery,
OUT stateid4 stateid,
OUT open_delegation4 delegation,
OUT OPTIONAL nfs41_file_info info 
)

Definition at line 366 of file nfs41_ops.c.

381{
382 int status;
383 nfs41_compound compound;
384 nfs_argop4 argops[8];
385 nfs_resop4 resops[8];
386 nfs41_sequence_args sequence_args;
387 nfs41_sequence_res sequence_res;
388 nfs41_putfh_args putfh_args[2];
389 nfs41_putfh_res putfh_res[2];
390 nfs41_op_open_args open_args;
391 nfs41_op_open_res open_res;
392 nfs41_getfh_res getfh_res;
393 bitmap4 attr_request;
394 nfs41_getattr_args getattr_args;
395 nfs41_getattr_res getattr_res, pgetattr_res;
396 nfs41_savefh_res savefh_res;
397 nfs41_restorefh_res restorefh_res;
398 nfs41_file_info tmp_info, dir_info;
399 bool_t current_fh_is_dir;
400 bool_t already_delegated = delegation->type == OPEN_DELEGATE_READ
401 || delegation->type == OPEN_DELEGATE_WRITE;
402
403 /* depending on the claim type, OPEN expects CURRENT_FH set
404 * to either the parent directory, or to the file itself */
405 switch (claim->claim) {
406 case CLAIM_NULL:
409 /* CURRENT_FH: directory */
410 current_fh_is_dir = TRUE;
411 /* SEQUENCE; PUTFH(dir); SAVEFH; OPEN;
412 * GETFH(file); GETATTR(file); RESTOREFH(dir); GETATTR */
413 nfs41_superblock_getattr_mask(parent->fh.superblock, &attr_request);
414 break;
415 case CLAIM_PREVIOUS:
416 case CLAIM_FH:
419 default:
420 /* CURRENT_FH: file being opened */
421 current_fh_is_dir = FALSE;
422 /* SEQUENCE; PUTFH(file); OPEN; GETATTR(file); PUTFH(dir); GETATTR */
423 nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
424 break;
425 }
426
427 if (info == NULL)
428 info = &tmp_info;
429
430 attr_request.arr[0] |= FATTR4_WORD0_FSID;
431
432 compound_init(&compound, argops, resops, "open");
433
434 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
435 nfs41_session_sequence(&sequence_args, session, 1);
436
437 if (current_fh_is_dir) {
438 /* CURRENT_FH: directory */
439 compound_add_op(&compound, OP_PUTFH, &putfh_args[0], &putfh_res[0]);
440 putfh_args[0].file = parent;
441 putfh_args[0].in_recovery = 0;
442
443 compound_add_op(&compound, OP_SAVEFH, NULL, &savefh_res);
444 } else {
445 /* CURRENT_FH: file being opened */
446 compound_add_op(&compound, OP_PUTFH, &putfh_args[0], &putfh_res[0]);
447 putfh_args[0].file = file;
448 putfh_args[0].in_recovery = 0;
449 }
450
451 compound_add_op(&compound, OP_OPEN, &open_args, &open_res);
452 open_args.seqid = 0;
453#ifdef DISABLE_FILE_DELEGATIONS
455#else
456 open_args.share_access = allow;
457#endif
458 open_args.share_deny = deny;
459 open_args.owner = owner;
460 open_args.openhow.opentype = create;
461 open_args.openhow.how.mode = how_mode;
462 open_args.openhow.how.createattrs = createattrs;
463 if (how_mode == EXCLUSIVE4_1) {
465 time((time_t*)open_args.openhow.how.createverf);
466 memcpy(open_args.openhow.how.createverf+4, &tid, sizeof(tid));
467 /* mask unsupported attributes */
469 parent->fh.superblock, &createattrs->attrmask);
470 } else if (createattrs) {
471 /* mask unsupported attributes */
473 parent->fh.superblock, &createattrs->attrmask);
474 }
475 open_args.claim = claim;
476 open_res.resok4.stateid = stateid;
477 open_res.resok4.delegation = delegation;
478
479 if (current_fh_is_dir) {
480 compound_add_op(&compound, OP_GETFH, NULL, &getfh_res);
481 getfh_res.fh = &file->fh;
482 }
483
484 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
485 getattr_args.attr_request = &attr_request;
487 getattr_res.info = info;
488
489 if (current_fh_is_dir) {
490 compound_add_op(&compound, OP_RESTOREFH, NULL, &restorefh_res);
491 } else {
492 compound_add_op(&compound, OP_PUTFH, &putfh_args[1], &putfh_res[1]);
493 putfh_args[1].file = parent;
494 putfh_args[1].in_recovery = 0;
495 }
496
497 compound_add_op(&compound, OP_GETATTR, &getattr_args, &pgetattr_res);
498 getattr_args.attr_request = &attr_request;
500 pgetattr_res.info = &dir_info;
501
502 status = compound_encode_send_decode(session, &compound, try_recovery);
503 if (status)
504 goto out;
505
506 if (compound_error(status = compound.res.status))
507 goto out;
508
509 if (dir_info.type == NF4ATTRDIR) {
510 file->fh.superblock = parent->fh.superblock;
511 goto out;
512 }
513
514 /* fill in the file handle's fileid and superblock */
515 file->fh.fileid = info->fileid;
517 if (status)
518 goto out;
519
520 if (create == OPEN4_CREATE)
521 nfs41_superblock_space_changed(file->fh.superblock);
522
523 /* update the name/attr cache with the results */
524 open_update_cache(session, parent, file, try_recovery, delegation,
525 already_delegated, &open_res.resok4.cinfo, &pgetattr_res, &getattr_res);
526out:
527 return status;
528}
int32_t bool_t
Definition: types.h:101
__kernel_time_t time_t
Definition: linux.h:252
unsigned long DWORD
Definition: ntddk_ex.h:95
static TfClientId tid
static const struct access_res create[16]
Definition: package.c:7644
static __inline void nfs41_superblock_supported_attrs_exclcreat(IN const nfs41_superblock *superblock, IN OUT bitmap4 *attrs)
Definition: nfs41.h:460
@ NF4ATTRDIR
Definition: nfs41_const.h:301
static void open_update_cache(IN nfs41_session *session, IN nfs41_path_fh *parent, IN nfs41_path_fh *file, IN bool_t try_recovery, IN open_delegation4 *delegation, IN bool_t already_delegated, IN change_info4 *changeinfo, IN nfs41_getattr_res *dir_attrs, IN nfs41_getattr_res *file_attrs)
Definition: nfs41_ops.c:321
@ OPEN_DELEGATE_READ
Definition: nfs41_ops.h:587
@ OPEN_DELEGATE_WRITE
Definition: nfs41_ops.h:588
@ OPEN4_CREATE
Definition: nfs41_ops.h:554
@ EXCLUSIVE4_1
Definition: nfs41_ops.h:543
@ OP_OPEN
Definition: nfs41_ops.h:46
@ OPEN4_SHARE_ACCESS_WANT_NO_DELEG
Definition: nfs41_ops.h:578
@ CLAIM_NULL
Definition: nfs41_ops.h:593
@ CLAIM_PREVIOUS
Definition: nfs41_ops.h:594
@ CLAIM_DELEG_CUR_FH
Definition: nfs41_ops.h:598
@ CLAIM_DELEGATE_CUR
Definition: nfs41_ops.h:595
@ CLAIM_FH
Definition: nfs41_ops.h:597
@ CLAIM_DELEGATE_PREV
Definition: nfs41_ops.h:596
@ CLAIM_DELEG_PREV_FH
Definition: nfs41_ops.h:599
uint32_t arr[3]
Definition: nfs41_types.h:97
unsigned char createverf[NFS4_VERIFIER_SIZE]
Definition: nfs41_ops.h:549
nfs41_file_info * createattrs
Definition: nfs41_ops.h:548
uint32_t mode
Definition: nfs41_ops.h:547
state_owner4 * owner
Definition: nfs41_ops.h:645
uint32_t share_access
Definition: nfs41_ops.h:643
open_claim4 * claim
Definition: nfs41_ops.h:647
change_info4 cinfo
Definition: nfs41_ops.h:659
open_delegation4 * delegation
Definition: nfs41_ops.h:662
nfs41_op_open_res_ok resok4
Definition: nfs41_ops.h:668
createhow4 how
Definition: nfs41_ops.h:560
uint32_t opentype
Definition: nfs41_ops.h:558
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459

Referenced by do_open(), get_ea_value(), nfs41_delegation_to_open(), recover_open_grace(), recover_open_no_grace(), and set_ea_value().

◆ nfs41_read()

int nfs41_read ( IN nfs41_session session,
IN nfs41_path_fh file,
IN stateid_arg stateid,
IN uint64_t  offset,
IN uint32_t  count,
OUT unsigned char data_out,
OUT uint32_t data_len_out,
OUT bool_t eof_out 
)

Definition at line 774 of file nfs41_ops.c.

783{
784 int status;
785 nfs41_compound compound;
786 nfs_argop4 argops[4];
787 nfs_resop4 resops[4];
788 nfs41_sequence_args sequence_args;
789 nfs41_sequence_res sequence_res;
790 nfs41_putfh_args putfh_args;
791 nfs41_putfh_res putfh_res;
792 nfs41_read_args read_args;
793 nfs41_read_res read_res;
794
795 compound_init(&compound, argops, resops,
796 stateid->stateid.seqid == 0 ? "ds read" : "read");
797
798 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
799 nfs41_session_sequence(&sequence_args, session, 0);
800
801 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
802 putfh_args.file = file;
803 putfh_args.in_recovery = 0;
804
805 compound_add_op(&compound, OP_READ, &read_args, &read_res);
806 read_args.stateid = stateid;
807 read_args.offset = offset;
808 read_args.count = count;
809 read_res.resok4.data_len = count;
810 read_res.resok4.data = data_out;
811
813 if (status)
814 goto out;
815
816 if (compound_error(status = compound.res.status))
817 goto out;
818
819 *data_len_out = read_res.resok4.data_len;
820 *eof_out = read_res.resok4.eof;
821
822 /* we shouldn't ever see this, but a buggy server could
823 * send us into an infinite loop. return NFS4ERR_IO */
824 if (!read_res.resok4.data_len && !read_res.resok4.eof) {
826 eprintf("READ succeeded with len=0 and eof=0; returning %s\n",
828 }
829out:
830 return status;
831}
const char * nfs_error_string(int status)
Definition: daemon_debug.c:370
@ NFS4ERR_IO
Definition: nfs41_const.h:90
@ OP_READ
Definition: nfs41_ops.h:53
stateid_arg * stateid
Definition: nfs41_ops.h:684
uint32_t count
Definition: nfs41_ops.h:686
uint64_t offset
Definition: nfs41_ops.h:685
unsigned char * data
Definition: nfs41_ops.h:692
nfs41_read_res_ok resok4
Definition: nfs41_ops.h:698

Referenced by file_layout_read_thread(), get_ea_value(), and read_from_mds().

◆ nfs41_readdir()

int nfs41_readdir ( IN nfs41_session session,
IN nfs41_path_fh file,
IN bitmap4 attr_request,
IN nfs41_readdir_cookie cookie,
OUT unsigned char entries,
IN OUT uint32_t entries_len,
OUT bool_t eof_out 
)

Definition at line 1010 of file nfs41_ops.c.

1018{
1019 int status;
1020 nfs41_compound compound;
1021 nfs_argop4 argops[3];
1022 nfs_resop4 resops[3];
1023 nfs41_sequence_args sequence_args;
1024 nfs41_sequence_res sequence_res;
1025 nfs41_putfh_args putfh_args;
1026 nfs41_putfh_res putfh_res;
1027 nfs41_readdir_args readdir_args;
1028 nfs41_readdir_res readdir_res;
1029
1030 compound_init(&compound, argops, resops, "readdir");
1031
1032 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1033 nfs41_session_sequence(&sequence_args, session, 0);
1034
1035 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1036 putfh_args.file = file;
1037 putfh_args.in_recovery = 0;
1038
1039 compound_add_op(&compound, OP_READDIR, &readdir_args, &readdir_res);
1040 readdir_args.cookie.cookie = cookie->cookie;
1041 memcpy(readdir_args.cookie.verf, cookie->verf, NFS4_VERIFIER_SIZE);
1042 readdir_args.dircount = *entries_len;
1043 readdir_args.maxcount = *entries_len + sizeof(nfs41_readdir_res);
1044 readdir_args.attr_request = attr_request;
1045 readdir_res.reply.entries_len = *entries_len;
1046 readdir_res.reply.entries = entries;
1047 ZeroMemory(entries, readdir_args.dircount);
1048
1050 if (status)
1051 goto out;
1052
1053 if (compound_error(status = compound.res.status))
1054 goto out;
1055
1056 *entries_len = readdir_res.reply.entries_len;
1057 *eof_out = readdir_res.reply.eof;
1058 memcpy(cookie->verf, readdir_res.cookieverf, NFS4_VERIFIER_SIZE);
1059out:
1060 return status;
1061}
#define NFS4_VERIFIER_SIZE
Definition: nfs41_const.h:30
@ OP_READDIR
Definition: nfs41_ops.h:54
struct __nfs41_readdir_res nfs41_readdir_res
bitmap4 * attr_request
Definition: nfs41_ops.h:707
nfs41_readdir_cookie cookie
Definition: nfs41_ops.h:704
uint32_t entries_len
Definition: nfs41_ops.h:720
unsigned char * entries
Definition: nfs41_ops.h:721
nfs41_readdir_list reply
Definition: nfs41_ops.h:729
unsigned char cookieverf[NFS4_VERIFIER_SIZE]
Definition: nfs41_ops.h:728
Definition: cookie.c:34
#define ZeroMemory
Definition: winbase.h:1712

Referenced by handle_readdir(), and read_entire_dir().

◆ nfs41_readlink()

int nfs41_readlink ( IN nfs41_session session,
IN nfs41_path_fh file,
IN uint32_t  max_len,
OUT char link_out,
OUT uint32_t len_out 
)

Definition at line 1511 of file nfs41_ops.c.

1517{
1518 int status;
1519 nfs41_compound compound;
1520 nfs_argop4 argops[3];
1521 nfs_resop4 resops[3];
1522 nfs41_sequence_args sequence_args;
1523 nfs41_sequence_res sequence_res;
1524 nfs41_putfh_args putfh_args;
1525 nfs41_putfh_res putfh_res;
1526 nfs41_readlink_res readlink_res;
1527
1528 compound_init(&compound, argops, resops, "readlink");
1529
1530 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1531 nfs41_session_sequence(&sequence_args, session, 0);
1532
1533 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1534 putfh_args.file = file;
1535 putfh_args.in_recovery = 0;
1536
1537 compound_add_op(&compound, OP_READLINK, NULL, &readlink_res);
1538 readlink_res.link_len = max_len - 1;
1539 readlink_res.link = link_out;
1540
1542 if (status)
1543 goto out;
1544
1545 if (compound_error(status = compound.res.status))
1546 goto out;
1547
1548 link_out[readlink_res.link_len] = '\0';
1549 *len_out = readlink_res.link_len;
1550out:
1551 return status;
1552}
@ OP_READLINK
Definition: nfs41_ops.h:55

Referenced by handle_symlink(), and nfs41_symlink_target().

◆ nfs41_reclaim_complete()

enum nfsstat4 nfs41_reclaim_complete ( IN nfs41_session session)

Definition at line 268 of file nfs41_ops.c.

270{
271 enum nfsstat4 status = NFS4_OK;
272 nfs41_compound compound;
273 nfs_argop4 argops[2];
274 nfs_resop4 resops[2];
275 nfs41_sequence_args sequence_args;
276 nfs41_sequence_res sequence_res;
277 nfs41_reclaim_complete_res reclaim_res;
278
279 compound_init(&compound, argops, resops, "reclaim_complete");
280
281 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
282 nfs41_session_sequence(&sequence_args, session, 0);
283
284 compound_add_op(&compound, OP_RECLAIM_COMPLETE, NULL, &reclaim_res);
285
286 /* don't attempt to recover from BADSESSION */
288 if (status)
289 goto out;
290
291 compound_error(status = compound.res.status);
292out:
293 return status;
294}
@ NFS4_OK
Definition: nfs41_const.h:87
@ OP_RECLAIM_COMPLETE
Definition: nfs41_ops.h:88

Referenced by nfs41_recover_client_state(), nfs41_recover_sequence_flags(), recover_delegation_open(), recover_delegation_want(), recover_locks(), recover_open(), and root_client_create().

◆ nfs41_remove()

int nfs41_remove ( IN nfs41_session session,
IN nfs41_path_fh parent,
IN const nfs41_component target,
IN uint64_t  fileid 
)

Definition at line 1180 of file nfs41_ops.c.

1185{
1186 int status;
1187 nfs41_compound compound;
1188 nfs_argop4 argops[4];
1189 nfs_resop4 resops[4];
1190 nfs41_sequence_args sequence_args;
1191 nfs41_sequence_res sequence_res;
1192 nfs41_putfh_args putfh_args;
1193 nfs41_putfh_res putfh_res;
1194 nfs41_remove_args remove_args;
1195 nfs41_remove_res remove_res;
1196 nfs41_getattr_args getattr_args;
1197 nfs41_getattr_res getattr_res;
1198 bitmap4 attr_request;
1200
1201 nfs41_superblock_getattr_mask(parent->fh.superblock, &attr_request);
1202
1203 compound_init(&compound, argops, resops, "remove");
1204
1205 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1206 nfs41_session_sequence(&sequence_args, session, 1);
1207
1208 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1209 putfh_args.file = parent;
1210 putfh_args.in_recovery = 0;
1211
1212 compound_add_op(&compound, OP_REMOVE, &remove_args, &remove_res);
1213 remove_args.target = target;
1214
1215 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
1216 getattr_args.attr_request = &attr_request;
1218 getattr_res.info = &info;
1219
1221 if (status)
1222 goto out;
1223
1224 if (compound_error(status = compound.res.status))
1225 goto out;
1226
1227 if (info.type == NF4ATTRDIR)
1228 goto out;
1229
1230 /* update the attributes of the parent directory */
1231 memcpy(&info.attrmask, &getattr_res.obj_attributes.attrmask,
1232 sizeof(bitmap4));
1234 parent->fh.fileid, &info);
1235
1236 /* remove the target file from the cache */
1237 AcquireSRWLockShared(&parent->path->lock);
1239 parent->path->path, target, fileid, &remove_res.cinfo);
1240 ReleaseSRWLockShared(&parent->path->lock);
1241
1242 nfs41_superblock_space_changed(parent->fh.superblock);
1243out:
1244 return status;
1245}
int nfs41_name_cache_remove(IN struct nfs41_name_cache *cache, IN const char *path, IN const nfs41_component *name, IN uint64_t fileid, IN const change_info4 *cinfo)
Definition: name_cache.c:1066
@ OP_REMOVE
Definition: nfs41_ops.h:56
const nfs41_component * target
Definition: nfs41_ops.h:744
change_info4 cinfo
Definition: nfs41_ops.h:750

Referenced by cancel_open(), handle_close(), handle_nfs41_remove(), handle_open(), handle_symlink(), and set_ea_value().

◆ nfs41_rename()

int nfs41_rename ( IN nfs41_session session,
IN nfs41_path_fh src_dir,
IN const nfs41_component src_name,
IN nfs41_path_fh dst_dir,
IN const nfs41_component dst_name 
)

Definition at line 1247 of file nfs41_ops.c.

1253{
1254 int status;
1255 nfs41_compound compound;
1256 nfs_argop4 argops[8];
1257 nfs_resop4 resops[8];
1258 nfs41_sequence_args sequence_args;
1259 nfs41_sequence_res sequence_res;
1260 nfs41_putfh_args src_putfh_args;
1261 nfs41_putfh_res src_putfh_res;
1262 nfs41_savefh_res savefh_res;
1263 nfs41_putfh_args dst_putfh_args;
1264 nfs41_putfh_res dst_putfh_res;
1265 nfs41_rename_args rename_args;
1266 nfs41_rename_res rename_res;
1267 nfs41_getattr_args getattr_args;
1268 nfs41_getattr_res src_getattr_res, dst_getattr_res;
1269 nfs41_file_info src_info, dst_info;
1270 bitmap4 attr_request;
1271 nfs41_restorefh_res restorefh_res;
1272
1273 nfs41_superblock_getattr_mask(src_dir->fh.superblock, &attr_request);
1274
1275 compound_init(&compound, argops, resops, "rename");
1276
1277 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1278 nfs41_session_sequence(&sequence_args, session, 1);
1279
1280 compound_add_op(&compound, OP_PUTFH, &src_putfh_args, &src_putfh_res);
1281 src_putfh_args.file = src_dir;
1282 src_putfh_args.in_recovery = 0;
1283
1284 compound_add_op(&compound, OP_SAVEFH, NULL, &savefh_res);
1285
1286 compound_add_op(&compound, OP_PUTFH, &dst_putfh_args, &dst_putfh_res);
1287 dst_putfh_args.file = dst_dir;
1288 dst_putfh_args.in_recovery = 0;
1289
1290 compound_add_op(&compound, OP_RENAME, &rename_args, &rename_res);
1291 rename_args.oldname = src_name;
1292 rename_args.newname = dst_name;
1293
1294 compound_add_op(&compound, OP_GETATTR, &getattr_args, &dst_getattr_res);
1295 getattr_args.attr_request = &attr_request;
1297 dst_getattr_res.info = &dst_info;
1298
1299 compound_add_op(&compound, OP_RESTOREFH, NULL, &restorefh_res);
1300
1301 compound_add_op(&compound, OP_GETATTR, &getattr_args, &src_getattr_res);
1303 src_getattr_res.info = &src_info;
1304
1306 if (status)
1307 goto out;
1308
1309 if (compound_error(status = compound.res.status))
1310 goto out;
1311
1312 /* update the attributes of the source directory */
1313 memcpy(&src_info.attrmask, &src_getattr_res.obj_attributes.attrmask,
1314 sizeof(bitmap4));
1316 src_dir->fh.fileid, &src_info);
1317
1318 /* update the attributes of the destination directory */
1319 memcpy(&dst_info.attrmask, &dst_getattr_res.obj_attributes.attrmask,
1320 sizeof(bitmap4));
1322 dst_dir->fh.fileid, &dst_info);
1323
1324 if (src_dir->path == dst_dir->path) {
1325 /* source and destination are the same, only lock it once */
1326 AcquireSRWLockShared(&src_dir->path->lock);
1327 } else if (src_dir->path < dst_dir->path) {
1328 /* lock the lowest memory address first */
1329 AcquireSRWLockShared(&src_dir->path->lock);
1330 AcquireSRWLockShared(&dst_dir->path->lock);
1331 } else {
1332 AcquireSRWLockShared(&dst_dir->path->lock);
1333 AcquireSRWLockShared(&src_dir->path->lock);
1334 }
1335
1336 /* move/rename the target file's name cache entry */
1338 src_dir->path->path, src_name, &rename_res.source_cinfo,
1339 dst_dir->path->path, dst_name, &rename_res.target_cinfo);
1340
1341 if (src_dir->path == dst_dir->path) {
1342 ReleaseSRWLockShared(&src_dir->path->lock);
1343 } else {
1344 ReleaseSRWLockShared(&src_dir->path->lock);
1345 ReleaseSRWLockShared(&dst_dir->path->lock);
1346 }
1347out:
1348 return status;
1349}
int nfs41_name_cache_rename(IN struct nfs41_name_cache *cache, IN const char *src_path, IN const nfs41_component *src_name, IN const change_info4 *src_cinfo, IN const char *dst_path, IN const nfs41_component *dst_name, IN const change_info4 *dst_cinfo)
Definition: name_cache.c:1122
@ OP_RENAME
Definition: nfs41_ops.h:57
const nfs41_component * oldname
Definition: nfs41_ops.h:756
const nfs41_component * newname
Definition: nfs41_ops.h:757
change_info4 target_cinfo
Definition: nfs41_ops.h:764
change_info4 source_cinfo
Definition: nfs41_ops.h:763

◆ nfs41_rpc_openattr()

enum nfsstat4 nfs41_rpc_openattr ( IN nfs41_session session,
IN nfs41_path_fh file,
IN bool_t  createdir,
OUT nfs41_fh fh_out 
)

Definition at line 2145 of file nfs41_ops.c.

2150{
2151 enum nfsstat4 status;
2152 nfs41_compound compound;
2153 nfs_argop4 argops[4];
2154 nfs_resop4 resops[4];
2155 nfs41_sequence_args sequence_args;
2156 nfs41_sequence_res sequence_res;
2157 nfs41_putfh_args putfh_args;
2158 nfs41_putfh_res putfh_res;
2159 nfs41_openattr_args openattr_args;
2160 nfs41_openattr_res openattr_res;
2161 nfs41_getfh_res getfh_res;
2162
2163 compound_init(&compound, argops, resops, "openattr");
2164
2165 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
2166 nfs41_session_sequence(&sequence_args, session, 0);
2167
2168 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
2169 putfh_args.file = file;
2170 putfh_args.in_recovery = FALSE;
2171
2172 compound_add_op(&compound, OP_OPENATTR, &openattr_args, &openattr_res);
2173 openattr_args.createdir = createdir;
2174
2175 compound_add_op(&compound, OP_GETFH, NULL, &getfh_res);
2176 getfh_res.fh = fh_out;
2177
2179 if (status)
2180 goto out;
2181
2182 compound_error(status = compound.res.status);
2183
2184 fh_out->superblock = file->fh.superblock;
2185out:
2186 return status;
2187}
@ OP_OPENATTR
Definition: nfs41_ops.h:47

Referenced by nfs41_ea_set().

◆ nfs41_secinfo()

int nfs41_secinfo ( IN nfs41_session session,
IN nfs41_path_fh file,
IN const nfs41_component name,
OUT nfs41_secinfo_info secinfo 
)

Definition at line 1785 of file nfs41_ops.c.

1790{
1791 int status;
1792 nfs41_compound compound;
1793 nfs_argop4 argops[3];
1794 nfs_resop4 resops[3];
1795 nfs41_sequence_args sequence_args;
1796 nfs41_sequence_res sequence_res;
1797 nfs41_putfh_args putfh_args;
1798 nfs41_putfh_res putfh_res;
1799 nfs41_secinfo_args secinfo_args;
1800 nfs41_secinfo_noname_res secinfo_res;
1801
1802 compound_init(&compound, argops, resops, "secinfo");
1803
1804 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1805 nfs41_session_sequence(&sequence_args, session, 0);
1806
1807 if (file == NULL)
1808 compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
1809 else {
1810 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1811 putfh_args.file = file;
1812 putfh_args.in_recovery = 0;
1813 }
1814
1815 compound_add_op(&compound, OP_SECINFO, &secinfo_args, &secinfo_res);
1816 secinfo_args.name = name;
1817 secinfo_res.secinfo = secinfo;
1818
1820 if (status)
1821 goto out;
1822
1823 compound_error(status = compound.res.status);
1824out:
1825 return status;
1826}
@ OP_SECINFO
Definition: nfs41_ops.h:61
const nfs41_component * name
Definition: nfs41_ops.h:878
nfs41_secinfo_info * secinfo
Definition: nfs41_ops.h:900

Referenced by compound_encode_send_decode().

◆ nfs41_secinfo_noname()

int nfs41_secinfo_noname ( IN nfs41_session session,
IN nfs41_path_fh file,
OUT nfs41_secinfo_info secinfo 
)

Definition at line 1828 of file nfs41_ops.c.

1832{
1833 int status;
1834 nfs41_compound compound;
1835 nfs_argop4 argops[3];
1836 nfs_resop4 resops[3];
1837 nfs41_sequence_args sequence_args;
1838 nfs41_sequence_res sequence_res;
1839 nfs41_putfh_args putfh_args;
1840 nfs41_putfh_res putfh_res;
1841 nfs41_secinfo_noname_args noname_args;
1842 nfs41_secinfo_noname_res noname_res;
1843
1844 compound_init(&compound, argops, resops, "secinfo_no_name");
1845
1846 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1847 nfs41_session_sequence(&sequence_args, session, 0);
1848
1849 if (file == NULL)
1850 compound_add_op(&compound, OP_PUTROOTFH, NULL, &putfh_res);
1851 else {
1852 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1853 putfh_args.file = file;
1854 putfh_args.in_recovery = 0;
1855 }
1856
1857 compound_add_op(&compound, OP_SECINFO_NO_NAME, &noname_args, &noname_res);
1858 noname_args.type = SECINFO_STYLE4_CURRENT_FH;
1859 noname_res.secinfo = secinfo;
1860
1862 if (status)
1863 goto out;
1864
1865 compound_error(status = compound.res.status);
1866out:
1867 return status;
1868}
@ OP_SECINFO_NO_NAME
Definition: nfs41_ops.h:82
@ SECINFO_STYLE4_CURRENT_FH
Definition: nfs41_ops.h:885
enum secinfo_noname_type type
Definition: nfs41_ops.h:893

Referenced by compound_encode_send_decode().

◆ nfs41_send_sequence()

int nfs41_send_sequence ( IN nfs41_session session)

Definition at line 1599 of file nfs41_ops.c.

1601{
1602 int status;
1603 nfs41_compound compound;
1604 nfs_argop4 argops[1];
1605 nfs_resop4 resops[1];
1606 nfs41_sequence_args sequence_args;
1607 nfs41_sequence_res sequence_res;
1608
1609 compound_init(&compound, argops, resops, "sequence");
1610
1611 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1612 nfs41_session_sequence(&sequence_args, session, 0);
1613
1615 if (status)
1616 goto out;
1617
1618 if (compound_error(status = compound.res.status))
1619 goto out;
1620out:
1621 return status;
1622}

Referenced by renew_session().

◆ nfs41_setattr()

int nfs41_setattr ( IN nfs41_session session,
IN nfs41_path_fh file,
IN stateid_arg stateid,
IN nfs41_file_info info 
)

Definition at line 1351 of file nfs41_ops.c.

1356{
1357 int status;
1358 nfs41_compound compound;
1359 nfs_argop4 argops[4];
1360 nfs_resop4 resops[4];
1361 nfs41_sequence_args sequence_args;
1362 nfs41_sequence_res sequence_res;
1363 nfs41_putfh_args putfh_args;
1364 nfs41_putfh_res putfh_res;
1365 nfs41_setattr_args setattr_args;
1366 nfs41_setattr_res setattr_res;
1367 nfs41_getattr_args getattr_args;
1368 nfs41_getattr_res getattr_res;
1369 bitmap4 attr_request;
1370
1371 compound_init(&compound, argops, resops, "setattr");
1372
1373 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1374 nfs41_session_sequence(&sequence_args, session, 0);
1375
1376 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1377 putfh_args.file = file;
1378 putfh_args.in_recovery = 0;
1379
1380 compound_add_op(&compound, OP_SETATTR, &setattr_args, &setattr_res);
1381 setattr_args.stateid = stateid;
1382 setattr_args.info = info;
1383
1384 nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
1385 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
1386 getattr_args.attr_request = &attr_request;
1388 getattr_res.info = info;
1389
1391 if (status)
1392 goto out;
1393
1394 if (compound_error(status = compound.res.status))
1395 goto out;
1396
1397 memcpy(&info->attrmask, &attr_request, sizeof(bitmap4));
1399 file->fh.fileid, info);
1400
1401 if (setattr_res.attrsset.arr[0] & FATTR4_WORD0_SIZE)
1402 nfs41_superblock_space_changed(file->fh.superblock);
1403out:
1404 return status;
1405}
@ FATTR4_WORD0_SIZE
Definition: nfs41_const.h:211
@ OP_SETATTR
Definition: nfs41_ops.h:62
stateid_arg * stateid
Definition: nfs41_ops.h:782
nfs41_file_info * info
Definition: nfs41_ops.h:783

Referenced by delegation_truncate(), handle_nfs41_set_size(), handle_setacl(), and handle_setexattr().

◆ nfs41_superblock_getattr()

int nfs41_superblock_getattr ( IN nfs41_session session,
IN nfs41_path_fh file,
IN bitmap4 attr_request,
OUT nfs41_file_info info,
OUT bool_t supports_named_attrs 
)

Definition at line 1116 of file nfs41_ops.c.

1122{
1123 int status;
1124 nfs41_compound compound;
1125 nfs_argop4 argops[4];
1126 nfs_resop4 resops[4];
1127 nfs41_sequence_args sequence_args;
1128 nfs41_sequence_res sequence_res;
1129 nfs41_putfh_args putfh_args;
1130 nfs41_putfh_res putfh_res;
1131 nfs41_getattr_args getattr_args;
1132 nfs41_getattr_res getattr_res;
1133 nfs41_openattr_args openattr_args;
1134 nfs41_openattr_res openattr_res;
1135
1136 compound_init(&compound, argops, resops, "getfsattr");
1137
1138 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1139 nfs41_session_sequence(&sequence_args, session, 0);
1140
1141 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1142 putfh_args.file = file;
1143 putfh_args.in_recovery = 0;
1144
1145 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
1146 getattr_args.attr_request = attr_request;
1148 getattr_res.info = info;
1149
1150 compound_add_op(&compound, OP_OPENATTR, &openattr_args, &openattr_res);
1151 openattr_args.createdir = 0;
1152
1154 if (status)
1155 goto out;
1156
1157 status = sequence_res.sr_status;
1158 if (status) goto out;
1159 status = putfh_res.status;
1160 if (status) goto out;
1161 status = getattr_res.status;
1162 if (status) goto out;
1163
1164 switch (status = openattr_res.status) {
1165 case NFS4ERR_NOTSUPP:
1166 *supports_named_attrs = 0;
1167 status = NFS4_OK;
1168 break;
1169
1170 case NFS4ERR_NOENT:
1171 case NFS4_OK:
1172 *supports_named_attrs = 1;
1173 status = NFS4_OK;
1174 break;
1175 }
1176out:
1177 return status;
1178}
@ NFS4ERR_NOTSUPP
Definition: nfs41_const.h:109
@ NFS4ERR_NOENT
Definition: nfs41_const.h:89
uint32_t status
Definition: nfs41_ops.h:515

Referenced by get_superblock_attrs().

◆ nfs41_test_stateid()

enum nfsstat4 nfs41_test_stateid ( IN nfs41_session session,
IN stateid_arg stateid_array,
IN uint32_t  count,
OUT uint32_t status_array 
)

Definition at line 1900 of file nfs41_ops.c.

1905{
1906 enum nfsstat4 status;
1907 nfs41_compound compound;
1908 nfs_argop4 argops[2];
1909 nfs_resop4 resops[2];
1910 nfs41_sequence_args sequence_args;
1911 nfs41_sequence_res sequence_res;
1912 nfs41_test_stateid_args teststateid_args;
1913 nfs41_test_stateid_res teststateid_res;
1914
1915 compound_init(&compound, argops, resops, "test_stateid");
1916
1917 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1918 nfs41_session_sequence(&sequence_args, session, 0);
1919
1920 compound_add_op(&compound, OP_TEST_STATEID, &teststateid_args, &teststateid_res);
1921 teststateid_args.stateids = stateid_array;
1922 teststateid_args.count = count;
1923 teststateid_res.resok.status = status_array;
1924 teststateid_res.resok.count = count;
1925
1927 if (status)
1928 goto out;
1929
1930 compound_error(status = compound.res.status);
1931out:
1932 return status;
1933}
static uint32_t stateid_array(IN struct list_entry *delegations, IN struct list_entry *opens, OUT stateid_arg **stateids_out, OUT uint32_t **statuses_out)
Definition: recovery.c:547
@ OP_TEST_STATEID
Definition: nfs41_ops.h:85
stateid_arg * stateids
Definition: nfs41_ops.h:822
struct __nfs41_test_stateid_res::@42 resok

Referenced by nfs41_client_state_revoked().

◆ nfs41_unlock()

int nfs41_unlock ( IN nfs41_session session,
IN nfs41_path_fh file,
IN uint64_t  offset,
IN uint64_t  length,
IN OUT stateid_arg stateid 
)

Definition at line 966 of file nfs41_ops.c.

972{
973 int status;
974 nfs41_compound compound;
975 nfs_argop4 argops[3];
976 nfs_resop4 resops[3];
977 nfs41_sequence_args sequence_args;
978 nfs41_sequence_res sequence_res;
979 nfs41_putfh_args putfh_args;
980 nfs41_putfh_res putfh_res;
981 nfs41_locku_args locku_args;
982 nfs41_locku_res locku_res;
983
984 compound_init(&compound, argops, resops, "unlock");
985
986 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
987 nfs41_session_sequence(&sequence_args, session, 0);
988
989 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
990 putfh_args.file = file;
991 putfh_args.in_recovery = 0;
992
993 compound_add_op(&compound, OP_LOCKU, &locku_args, &locku_res);
994 /* 18.12.3: the server MUST accept any legal value for locktype */
995 locku_args.locktype = READ_LT;
996 locku_args.offset = offset;
997 locku_args.length = length;
998 locku_args.lock_stateid = stateid;
999 locku_res.lock_stateid = &stateid->stateid;
1000
1002 if (status)
1003 goto out;
1004
1005 compound_error(status = compound.res.status);
1006out:
1007 return status;
1008}
@ OP_LOCKU
Definition: nfs41_ops.h:42
@ READ_LT
Definition: nfs41_ops.h:399
uint32_t locktype
Definition: nfs41_ops.h:476
stateid_arg * lock_stateid
Definition: nfs41_ops.h:478
stateid4 * lock_stateid
Definition: nfs41_ops.h:486

Referenced by cancel_lock(), and handle_unlock().

◆ nfs41_want_delegation()

enum nfsstat4 nfs41_want_delegation ( IN nfs41_session session,
IN nfs41_path_fh file,
IN deleg_claim4 claim,
IN uint32_t  want,
IN bool_t  try_recovery,
OUT open_delegation4 delegation 
)

Definition at line 1624 of file nfs41_ops.c.

1631{
1632 enum nfsstat4 status;
1633 nfs41_compound compound;
1634 nfs_argop4 argops[3];
1635 nfs_resop4 resops[3];
1636 nfs41_sequence_args sequence_args;
1637 nfs41_sequence_res sequence_res;
1638 nfs41_putfh_args putfh_args;
1639 nfs41_putfh_res putfh_res;
1642
1643 compound_init(&compound, argops, resops, "want_delegation");
1644
1645 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1646 nfs41_session_sequence(&sequence_args, session, 0);
1647
1648 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1649 putfh_args.file = file;
1650 putfh_args.in_recovery = 0;
1651
1652 compound_add_op(&compound, OP_WANT_DELEGATION, &wd_args, &wd_res);
1653 wd_args.claim = claim;
1654 wd_args.want = want;
1655 wd_res.delegation = delegation;
1656
1657 status = compound_encode_send_decode(session, &compound, try_recovery);
1658 if (status)
1659 goto out;
1660
1661 compound_error(status = compound.res.status);
1662out:
1663 return status;
1664}
@ OP_WANT_DELEGATION
Definition: nfs41_ops.h:86
open_delegation4 * delegation
Definition: nfs41_ops.h:807

Referenced by recover_delegation_want().

◆ nfs41_write()

int nfs41_write ( IN nfs41_session session,
IN nfs41_path_fh file,
IN stateid_arg stateid,
IN unsigned char data,
IN uint32_t  data_len,
IN uint64_t  offset,
IN enum stable_how4  stable,
OUT uint32_t bytes_written,
OUT nfs41_write_verf verf,
OUT nfs41_file_info cinfo 
)

Definition at line 685 of file nfs41_ops.c.

696{
697 int status;
698 nfs41_compound compound;
699 nfs_argop4 argops[4];
700 nfs_resop4 resops[4];
701 nfs41_sequence_args sequence_args;
702 nfs41_sequence_res sequence_res;
703 nfs41_putfh_args putfh_args;
704 nfs41_putfh_res putfh_res;
706 nfs41_write_res write_res;
707 nfs41_getattr_args getattr_args;
708 nfs41_getattr_res getattr_res = {0};
709 bitmap4 attr_request;
710 nfs41_file_info info = { 0 }, *pinfo;
711
712 nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
713
714 compound_init(&compound, argops, resops,
715 stateid->stateid.seqid == 0 ? "ds write" : "write");
716
717 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
718 nfs41_session_sequence(&sequence_args, session, 0);
719
720 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
721 putfh_args.file = file;
722 putfh_args.in_recovery = 0;
723
724 compound_add_op(&compound, OP_WRITE, &write_args, &write_res);
725 write_args.stateid = stateid;
726 write_args.offset = offset;
727 write_args.stable = stable;
728 write_args.data_len = data_len;
729 write_args.data = data;
730 write_res.resok4.verf = verf;
731
732 if (cinfo) pinfo = cinfo;
733 else pinfo = &info;
734
735 if (stable != UNSTABLE4) {
736 /* if the write is stable, we can't rely on COMMIT to update
737 * the attribute cache, so we do the GETATTR here */
738 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
739 getattr_args.attr_request = &attr_request;
741 getattr_res.info = pinfo;
742 }
743
745 if (status)
746 goto out;
747
748 if (compound_error(status = compound.res.status))
749 goto out;
750
751 if (stable != UNSTABLE4 && pinfo->type != NF4NAMEDATTR) {
752 /* update the attribute cache */
753 memcpy(&pinfo->attrmask, &getattr_res.obj_attributes.attrmask,
754 sizeof(bitmap4));
756 file->fh.fileid, pinfo);
757 }
758
759 *bytes_written = write_res.resok4.count;
760
761 /* we shouldn't ever see this, but a buggy server could
762 * send us into an infinite loop. return NFS4ERR_IO */
763 if (!write_res.resok4.count) {
765 eprintf("WRITE succeeded with count=0; returning %s\n",
767 }
768
769 nfs41_superblock_space_changed(file->fh.superblock);
770out:
771 return status;
772}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
@ UNSTABLE4
Definition: nfs41_ops.h:836
@ OP_WRITE
Definition: nfs41_ops.h:66
void write_args(FILE *h, const var_list_t *args, const char *name, int method, int do_indent)
Definition: header.c:1058
nfs41_write_verf * verf
Definition: nfs41_ops.h:851
nfs41_write_res_ok resok4
Definition: nfs41_ops.h:857

Referenced by file_layout_write_thread(), set_ea_value(), and write_to_mds().

◆ open_delegation_return()

static void open_delegation_return ( IN nfs41_session session,
IN nfs41_path_fh file,
IN open_delegation4 delegation,
IN bool_t  try_recovery 
)
static

Definition at line 296 of file nfs41_ops.c.

301{
302 stateid_arg stateid;
303 int status;
304
305 if (delegation->type == OPEN_DELEGATE_NONE ||
306 delegation->type == OPEN_DELEGATE_NONE_EXT)
307 return;
308
309 /* return the delegation */
310 stateid.open = NULL;
311 stateid.delegation = NULL;
312 stateid.type = STATEID_DELEG_FILE;
313 memcpy(&stateid.stateid, &delegation->stateid, sizeof(stateid4));
314
315 status = nfs41_delegreturn(session, file, &stateid, try_recovery);
316
317 /* clear the delegation type returned by nfs41_open() */
318 delegation->type = OPEN_DELEGATE_NONE;
319}
int nfs41_delegreturn(IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid_arg *stateid, IN bool_t try_recovery)
Definition: nfs41_ops.c:1693
@ OPEN_DELEGATE_NONE_EXT
Definition: nfs41_ops.h:589
@ STATEID_DELEG_FILE
Definition: nfs41_ops.h:278
enum stateid_type type
Definition: nfs41_ops.h:285
nfs41_open_state * open
Definition: nfs41_ops.h:286
stateid4 stateid
Definition: nfs41_ops.h:284
nfs41_delegation_state * delegation
Definition: nfs41_ops.h:287

Referenced by open_update_cache().

◆ open_update_cache()

static void open_update_cache ( IN nfs41_session session,
IN nfs41_path_fh parent,
IN nfs41_path_fh file,
IN bool_t  try_recovery,
IN open_delegation4 delegation,
IN bool_t  already_delegated,
IN change_info4 changeinfo,
IN nfs41_getattr_res dir_attrs,
IN nfs41_getattr_res file_attrs 
)
static

Definition at line 321 of file nfs41_ops.c.

331{
334
335 /* update the attributes of the parent directory */
336 memcpy(&dir_attrs->info->attrmask, &dir_attrs->obj_attributes.attrmask,
337 sizeof(bitmap4));
338 nfs41_attr_cache_update(cache, parent->fh.fileid, dir_attrs->info);
339
340 /* add the file handle and attributes to the name cache */
341 memcpy(&file_attrs->info->attrmask, &file_attrs->obj_attributes.attrmask,
342 sizeof(bitmap4));
343retry_cache_insert:
346 &file->fh, file_attrs->info, changeinfo,
347 already_delegated ? OPEN_DELEGATE_NONE : delegation->type);
349
351 /* the cache won't accept any more delegations; ask the client to
352 * return a delegation to free up a slot in the attribute cache */
354 if (status == NFS4_OK)
355 goto retry_cache_insert;
356 }
357
358 if (status && delegation->type != OPEN_DELEGATE_NONE) {
359 /* if we can't make room in the cache, return this
360 * delegation immediately to free resources on the server */
361 open_delegation_return(session, file, delegation, try_recovery);
362 goto retry_cache_insert;
363 }
364}
int nfs41_client_delegation_return_lru(IN nfs41_client *client)
Definition: delegation.c:902
UINT32 uint32_t
Definition: types.h:75
static void open_delegation_return(IN nfs41_session *session, IN nfs41_path_fh *file, IN open_delegation4 *delegation, IN bool_t try_recovery)
Definition: nfs41_ops.c:296
Definition: cache.c:49
#define ERROR_TOO_MANY_OPEN_FILES
Definition: winerror.h:107

Referenced by nfs41_open().

◆ pnfs_rpc_getdeviceinfo()

enum nfsstat4 pnfs_rpc_getdeviceinfo ( IN nfs41_session session,
IN unsigned char deviceid,
OUT pnfs_file_device device 
)

Definition at line 2109 of file nfs41_ops.c.

2113{
2114 enum nfsstat4 status;
2115 nfs41_compound compound;
2116 nfs_argop4 argops[2];
2117 nfs_resop4 resops[2];
2118 nfs41_sequence_args sequence_args;
2119 nfs41_sequence_res sequence_res;
2120 pnfs_getdeviceinfo_args getdeviceinfo_args;
2121 pnfs_getdeviceinfo_res getdeviceinfo_res;
2122
2123 compound_init(&compound, argops, resops, "get_deviceinfo");
2124
2125 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
2126 nfs41_session_sequence(&sequence_args, session, 0);
2127
2129 &getdeviceinfo_args, &getdeviceinfo_res);
2130 getdeviceinfo_args.deviceid = deviceid;
2131 getdeviceinfo_args.layout_type = PNFS_LAYOUTTYPE_FILE;
2132 getdeviceinfo_args.maxcount = NFS41_MAX_SERVER_CACHE; /* XXX */
2133 getdeviceinfo_args.notify_types.count = 0;
2134 getdeviceinfo_res.u.res_ok.device = device;
2135
2137 if (status)
2138 goto out;
2139
2140 compound_error(status = compound.res.status);
2141out:
2142 return status;
2143}
#define NFS41_MAX_SERVER_CACHE
Definition: nfs41_const.h:39
@ OP_GETDEVICEINFO
Definition: nfs41_ops.h:77
@ PNFS_LAYOUTTYPE_FILE
Definition: pnfs.h:75
uint32_t count
Definition: nfs41_types.h:96
enum pnfs_layout_type layout_type
Definition: nfs41_ops.h:977
unsigned char * deviceid
Definition: nfs41_ops.h:976
pnfs_file_device * device
Definition: nfs41_ops.h:983
pnfs_getdeviceinfo_res_ok res_ok
Definition: nfs41_ops.h:991
union __pnfs_getdeviceinfo_res::@44 u
Definition: devices.h:37

Referenced by pnfs_file_device_get().

◆ pnfs_rpc_layoutcommit()

enum nfsstat4 pnfs_rpc_layoutcommit ( IN nfs41_session session,
IN nfs41_path_fh file,
IN stateid4 stateid,
IN uint64_t  offset,
IN uint64_t  length,
IN OPTIONAL uint64_t new_last_offset,
IN OPTIONAL nfstime4 new_time_modify,
OUT nfs41_file_info info 
)

Definition at line 1999 of file nfs41_ops.c.

2008{
2009 enum nfsstat4 status;
2010 nfs41_compound compound;
2011 nfs_argop4 argops[4];
2012 nfs_resop4 resops[4];
2013 nfs41_sequence_args sequence_args;
2014 nfs41_sequence_res sequence_res;
2015 nfs41_putfh_args putfh_args;
2016 nfs41_putfh_res putfh_res;
2017 pnfs_layoutcommit_args lc_args;
2018 pnfs_layoutcommit_res lc_res;
2019 nfs41_getattr_args getattr_args;
2020 nfs41_getattr_res getattr_res;
2021 bitmap4 attr_request;
2022
2023 nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
2024
2025 compound_init(&compound, argops, resops, "layoutcommit");
2026
2027 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
2028 nfs41_session_sequence(&sequence_args, session, 0);
2029
2030 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
2031 putfh_args.file = file;
2032 putfh_args.in_recovery = 0;
2033
2034 compound_add_op(&compound, OP_LAYOUTCOMMIT, &lc_args, &lc_res);
2035 lc_args.offset = offset;
2036 lc_args.length = length;
2037 lc_args.stateid = stateid;
2038 lc_args.new_time = new_time_modify;
2039 lc_args.new_offset = new_last_offset;
2040
2041 compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res);
2042 getattr_args.attr_request = &attr_request;
2044 getattr_res.info = info;
2045
2047 if (status)
2048 goto out;
2049
2050 if (compound_error(status = compound.res.status))
2051 goto out;
2052
2053 /* update the attribute cache */
2054 memcpy(&info->attrmask, &getattr_res.obj_attributes.attrmask,
2055 sizeof(bitmap4));
2057 file->fh.fileid, info);
2058out:
2059 return status;
2060}
@ OP_LAYOUTCOMMIT
Definition: nfs41_ops.h:79

Referenced by layout_commit().

◆ pnfs_rpc_layoutget()

enum nfsstat4 pnfs_rpc_layoutget ( IN nfs41_session session,
IN nfs41_path_fh file,
IN stateid_arg stateid,
IN enum pnfs_iomode  iomode,
IN uint64_t  offset,
IN uint64_t  minlength,
IN uint64_t  length,
OUT pnfs_layoutget_res_ok layoutget_res_ok 
)

Definition at line 1935 of file nfs41_ops.c.

1944{
1945 enum nfsstat4 status;
1946 nfs41_compound compound;
1947 nfs_argop4 argops[3];
1948 nfs_resop4 resops[3];
1949 nfs41_sequence_args sequence_args;
1950 nfs41_sequence_res sequence_res;
1951 nfs41_putfh_args putfh_args;
1952 nfs41_putfh_res putfh_res;
1953 pnfs_layoutget_args layoutget_args;
1954 pnfs_layoutget_res layoutget_res = { 0 };
1955 uint32_t i;
1956 struct list_entry *entry;
1957
1958 compound_init(&compound, argops, resops, "layoutget");
1959
1960 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
1961 nfs41_session_sequence(&sequence_args, session, 0);
1962
1963 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
1964 putfh_args.file = file;
1965 putfh_args.in_recovery = 0;
1966
1967 compound_add_op(&compound, OP_LAYOUTGET, &layoutget_args, &layoutget_res);
1968 layoutget_args.signal_layout_avail = 0;
1969 layoutget_args.layout_type = PNFS_LAYOUTTYPE_FILE;
1970 layoutget_args.iomode = iomode;
1971 layoutget_args.offset = offset;
1972 layoutget_args.minlength = minlength;
1973 layoutget_args.length = length;
1974 layoutget_args.stateid = stateid;
1975 layoutget_args.maxcount = session->fore_chan_attrs.ca_maxresponsesize - READ_OVERHEAD;
1976
1977 layoutget_res.u.res_ok = layoutget_res_ok;
1978
1980 if (status)
1981 goto out;
1982
1983 if (compound_error(status = compound.res.status))
1984 goto out;
1985
1986 /* point each file handle to the meta server's superblock */
1987 list_for_each(entry, &layoutget_res_ok->layouts) {
1989 if (base->type == PNFS_LAYOUTTYPE_FILE) {
1991 for (i = 0; i < layout->filehandles.count; i++)
1992 layout->filehandles.arr[i].fh.superblock = file->fh.superblock;
1993 }
1994 }
1995out:
1996 return status;
1997}
#define list_container(entry, type, field)
Definition: list.h:33
#define list_for_each(entry, head)
Definition: list.h:36
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uint32_t entry
Definition: isohybrid.c:63
static DWORD layout
Definition: bitmap.c:46
#define READ_OVERHEAD
Definition: nfs41_const.h:68
@ OP_LAYOUTGET
Definition: nfs41_ops.h:80
enum pnfs_iomode iomode
Definition: nfs41_ops.h:908
bool_t signal_layout_avail
Definition: nfs41_ops.h:906
enum pnfs_layout_type layout_type
Definition: nfs41_ops.h:907
stateid_arg * stateid
Definition: nfs41_ops.h:912
pnfs_layoutget_res_ok * res_ok
Definition: nfs41_ops.h:927
union __pnfs_layoutget_res::@43 u
Definition: list.h:27

Referenced by file_layout_fetch().

◆ pnfs_rpc_layoutreturn()

enum nfsstat4 pnfs_rpc_layoutreturn ( IN nfs41_session session,
IN nfs41_path_fh file,
IN enum pnfs_layout_type  type,
IN enum pnfs_iomode  iomode,
IN uint64_t  offset,
IN uint64_t  length,
IN stateid4 stateid,
OUT pnfs_layoutreturn_res layoutreturn_res 
)

Definition at line 2062 of file nfs41_ops.c.

2071{
2072 enum nfsstat4 status;
2073 nfs41_compound compound;
2074 nfs_argop4 argops[3];
2075 nfs_resop4 resops[3];
2076 nfs41_sequence_args sequence_args;
2077 nfs41_sequence_res sequence_res;
2078 nfs41_putfh_args putfh_args;
2079 nfs41_putfh_res putfh_res;
2080 pnfs_layoutreturn_args layoutreturn_args;
2081
2082 compound_init(&compound, argops, resops, "layoutreturn");
2083
2084 compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
2085 nfs41_session_sequence(&sequence_args, session, 0);
2086
2087 compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res);
2088 putfh_args.file = file;
2089 putfh_args.in_recovery = 0;
2090
2091 compound_add_op(&compound, OP_LAYOUTRETURN, &layoutreturn_args, layoutreturn_res);
2092 layoutreturn_args.reclaim = 0;
2093 layoutreturn_args.type = type;
2094 layoutreturn_args.iomode = iomode;
2095 layoutreturn_args.return_type = PNFS_RETURN_FILE;
2096 layoutreturn_args.offset = offset;
2097 layoutreturn_args.length = length;
2098 layoutreturn_args.stateid = stateid;
2099
2101 if (status)
2102 goto out;
2103
2104 compound_error(status = compound.res.status);
2105out:
2106 return status;
2107}
@ OP_LAYOUTRETURN
Definition: nfs41_ops.h:81
@ PNFS_RETURN_FILE
Definition: pnfs.h:101
enum pnfs_layout_type type
Definition: nfs41_ops.h:956
enum pnfs_iomode iomode
Definition: nfs41_ops.h:957
enum pnfs_return_type return_type
Definition: nfs41_ops.h:958

Referenced by file_layout_return().

◆ set_back_channel_attrs()

static int set_back_channel_attrs ( IN nfs41_rpc_clnt rpc,
IN uint32_t  max_req,
OUT nfs41_channel_attrs attrs 
)
static

Definition at line 86 of file nfs41_ops.c.

90{
91 attrs->ca_headerpadsize = 0;
92 attrs->ca_maxrequestsize = rpc->wsize;
93 attrs->ca_maxresponsesize = rpc->rsize;
94 attrs->ca_maxresponsesize_cached = NFS41_MAX_SERVER_CACHE;
95 attrs->ca_maxoperations = 0xffffffff;
96 attrs->ca_maxrequests = max_req;
97 attrs->ca_rdma_ird = NULL;
98 return 0;
99}

Referenced by nfs41_create_session().

◆ set_fore_channel_attrs()

static int set_fore_channel_attrs ( IN nfs41_rpc_clnt rpc,
IN uint32_t  max_req,
OUT nfs41_channel_attrs attrs 
)
static

Definition at line 70 of file nfs41_ops.c.

74{
75 attrs->ca_headerpadsize = 0;
76 attrs->ca_maxrequestsize = rpc->wsize;
77 attrs->ca_maxresponsesize = rpc->rsize;
78 attrs->ca_maxresponsesize_cached = NFS41_MAX_SERVER_CACHE;
79 attrs->ca_maxoperations = 0xffffffff;
80 attrs->ca_maxrequests = max_req;
81 attrs->ca_rdma_ird = NULL;
82 return 0;
83}

Referenced by nfs41_create_session().