summaryrefslogtreecommitdiffstats
path: root/tests/basic/gfapi/upcall-cache-invalidate.c
diff options
context:
space:
mode:
authorShyamsundarR <srangana@redhat.com>2017-08-21 10:17:00 -0400
committerShyamsundar Ranganathan <srangana@redhat.com>2017-08-21 14:41:10 +0000
commitdd281c7c154ded8210696d41d28bd19a96d79465 (patch)
treee22ad2cde1958a742fcd12a64037cd145eda6669 /tests/basic/gfapi/upcall-cache-invalidate.c
parent4fe845d41f45045947c7ef6817bf0b5d0d3fe074 (diff)
doc: Minor edit to release notes for 3.11.3v3.11.3release-3.11
Change-Id: Ib1f4bac62fdd01b3e5e97582b5464b14c1fb9a8e BUG: 1473776 Signed-off-by: ShyamsundarR <srangana@redhat.com> Reviewed-on: https://review.gluster.org/18079 CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'tests/basic/gfapi/upcall-cache-invalidate.c')
0 files changed, 0 insertions, 0 deletions
de |= NFS3MODE_ROWNER; if (IA_PROT_WUSR (buf->ia_prot)) fa.mode |= NFS3MODE_WOWNER; if (IA_PROT_XUSR (buf->ia_prot)) fa.mode |= NFS3MODE_XOWNER; if (IA_PROT_RGRP (buf->ia_prot)) fa.mode |= NFS3MODE_RGROUP; if (IA_PROT_WGRP (buf->ia_prot)) fa.mode |= NFS3MODE_WGROUP; if (IA_PROT_XGRP (buf->ia_prot)) fa.mode |= NFS3MODE_XGROUP; if (IA_PROT_ROTH (buf->ia_prot)) fa.mode |= NFS3MODE_ROTHER; if (IA_PROT_WOTH (buf->ia_prot)) fa.mode |= NFS3MODE_WOTHER; if (IA_PROT_XOTH (buf->ia_prot)) fa.mode |= NFS3MODE_XOTHER; if (IA_PROT_SUID (buf->ia_prot)) fa.mode |= NFS3MODE_SETXUID; if (IA_PROT_SGID (buf->ia_prot)) fa.mode |= NFS3MODE_SETXGID; if (IA_PROT_STCKY (buf->ia_prot)) fa.mode |= NFS3MODE_SAVESWAPTXT; fa.nlink = buf->ia_nlink; fa.uid = buf->ia_uid; fa.gid = buf->ia_gid; fa.size = buf->ia_size; fa.used = (buf->ia_blocks * 512); if ((IA_ISCHR (buf->ia_type) || IA_ISBLK (buf->ia_type))) { fa.rdev.specdata1 = ia_major (buf->ia_rdev); fa.rdev.specdata2 = ia_minor (buf->ia_rdev); } else { fa.rdev.specdata1 = 0; fa.rdev.specdata2 = 0; } fa.fsid = buf->ia_dev; fa.fileid = buf->ia_ino; /* FIXME: Handle time resolutions for sub-second granularity */ if (buf->ia_atime == 9669) { fa.mtime.seconds = 0; fa.mtime.nseconds = 0; fa.atime.seconds = 0; fa.atime.nseconds = 0; } else { fa.mtime.seconds = buf->ia_mtime; fa.mtime.nseconds = 0; fa.atime.seconds = buf->ia_atime; fa.atime.seconds = 0; fa.atime.nseconds = 0; } fa.atime.seconds = buf->ia_atime; fa.atime.nseconds = 0; fa.ctime.seconds = buf->ia_ctime; fa.ctime.nseconds = 0; return fa; } post_op_attr nfs3_stat_to_post_op_attr (struct iatt *buf) { post_op_attr attr = {0, }; if (!buf) return attr; /* Some performance translators return zero-filled stats when they * do not have up-to-date attributes. Need to handle this by not * returning these zeroed out attrs. */ attr.attributes_follow = FALSE; if (nfs_zero_filled_stat (buf)) goto out; attr.post_op_attr_u.attributes = nfs3_stat_to_fattr3 (buf); attr.attributes_follow = TRUE; out: return attr; } pre_op_attr nfs3_stat_to_pre_op_attr (struct iatt *pre) { pre_op_attr poa = {0, }; /* Some performance translators return zero-filled stats when they * do not have up-to-date attributes. Need to handle this by not * returning these zeroed out attrs. */ poa.attributes_follow = FALSE; if (nfs_zero_filled_stat (pre)) goto out; poa.attributes_follow = TRUE; poa.pre_op_attr_u.attributes.size = pre->ia_size; if (pre->ia_atime == 9669) poa.pre_op_attr_u.attributes.mtime.seconds = 0; else poa.pre_op_attr_u.attributes.mtime.seconds = pre->ia_mtime; poa.pre_op_attr_u.attributes.ctime.seconds = pre->ia_ctime; out: return poa; } void nfs3_fill_lookup3res_success (lookup3res *res, nfsstat3 stat, struct nfs3_fh *fh, struct iatt *buf, struct iatt *postparent) { post_op_attr obj, dir; uint32_t fhlen = 0; res->status = stat; if (fh) { res->lookup3res_u.resok.object.data.data_val = (void *)fh; fhlen = nfs3_fh_compute_size (fh); res->lookup3res_u.resok.object.data.data_len = fhlen; } obj.attributes_follow = FALSE; dir.attributes_follow = FALSE; if (buf) obj = nfs3_stat_to_post_op_attr (buf); if (postparent) dir = nfs3_stat_to_post_op_attr (postparent); res->lookup3res_u.resok.obj_attributes = obj; res->lookup3res_u.resok.dir_attributes = dir; } void nfs3_fill_lookup3res (lookup3res *res, nfsstat3 stat, struct nfs3_fh *newfh, struct iatt *buf, struct iatt *postparent, uint64_t deviceid) { memset (res, 0, sizeof (*res)); nfs3_map_deviceid_to_statdev (buf, deviceid); nfs3_map_deviceid_to_statdev (postparent, deviceid); if (stat != NFS3_OK) nfs3_fill_lookup3res_error (res, stat, postparent); else nfs3_fill_lookup3res_success (res, stat, newfh, buf, postparent); } struct nfs3_fh nfs3_extract_getattr_fh (getattr3args *args) { return nfs3_extract_nfs3_fh(args->object); } void nfs3_fill_getattr3res (getattr3res *res, nfsstat3 stat, struct iatt *buf, uint64_t deviceid) { memset (res, 0, sizeof (*res)); res->status = stat; if (stat != NFS3_OK) return; nfs3_map_deviceid_to_statdev (buf, deviceid); res->getattr3res_u.resok.obj_attributes = nfs3_stat_to_fattr3 (buf); } struct nfs3_fh nfs3_extract_fsinfo_fh (fsinfo3args *args) { return nfs3_extract_nfs3_fh (args->fsroot); } void nfs3_fill_fsinfo3res (struct nfs3_state *nfs3, fsinfo3res *res, nfsstat3 status, struct iatt *fsroot, uint64_t deviceid) { fsinfo3resok resok = {{0}, }; nfstime3 tdelta = GF_NFS3_TIMEDELTA_SECS; memset (res, 0, sizeof (*res)); res->status = status; if (status != NFS3_OK) return; nfs3_map_deviceid_to_statdev (fsroot, deviceid); resok.obj_attributes = nfs3_stat_to_post_op_attr (fsroot); resok.rtmax = nfs3->readsize; resok.rtpref = nfs3->readsize; resok.rtmult = GF_NFS3_RTMULT; resok.wtmax = nfs3->writesize; resok.wtpref = nfs3->writesize; resok.wtmult = GF_NFS3_WTMULT; resok.dtpref = nfs3->readdirsize; resok.maxfilesize = GF_NFS3_MAXFILE; resok.time_delta = tdelta; resok.properties = GF_NFS3_FS_PROP; res->fsinfo3res_u.resok = resok; } void nfs3_prep_lookup3args (lookup3args *args, struct nfs3_fh *fh, char *name) { memset (args, 0, sizeof (*args)); args->what.dir.data.data_val = (void *)fh; args->what.name = name; } void nfs3_prep_getattr3args (getattr3args *args, struct nfs3_fh *fh) { memset (args, 0, sizeof (*args)); args->object.data.data_val = (void *)fh; } void nfs3_prep_fsinfo3args (fsinfo3args *args, struct nfs3_fh *root) { memset (args, 0, sizeof (*args)); args->fsroot.data.data_val = (void *)root; } char * nfsstat3_strerror(int stat) { int i; for(i = 0; nfs3stat_strerror_table[i].stat != -1; i++) { if (nfs3stat_strerror_table[i].stat == stat) return nfs3stat_strerror_table[i].strerror; } return nfs3stat_strerror_table[i].strerror; } void nfs3_prep_access3args (access3args *args, struct nfs3_fh *fh) { memset (args, 0, sizeof (*args)); args->object.data.data_val = (void *)fh; } uint32_t nfs3_owner_accessbits (ia_prot_t prot, ia_type_t type, uint32_t request) { uint32_t accresult = 0; if (IA_PROT_RUSR (prot) && (request & ACCESS3_READ)) accresult |= ACCESS3_READ; if (request & ACCESS3_LOOKUP) if ((IA_ISDIR (type)) && (IA_PROT_XUSR (prot))) accresult |= ACCESS3_LOOKUP; if ((IA_PROT_WUSR (prot) && (request & ACCESS3_MODIFY))) accresult |= ACCESS3_MODIFY; if ((IA_PROT_WUSR (prot) && (request & ACCESS3_EXTEND))) accresult |= ACCESS3_EXTEND; /* ACCESS3_DELETE is ignored for now since that requires * knowing the permissions on the parent directory. */ if (request & ACCESS3_EXECUTE) if (IA_PROT_XUSR (prot) && (!IA_ISDIR (type))) accresult |= ACCESS3_EXECUTE; return accresult; } uint32_t nfs3_group_accessbits (ia_prot_t prot, ia_type_t type, uint32_t request) { uint32_t accresult = 0; if (IA_PROT_RGRP (prot) && (request & ACCESS3_READ)) accresult |= ACCESS3_READ; if (request & ACCESS3_LOOKUP) if ((IA_ISDIR (type)) && IA_PROT_RGRP (prot)) accresult |= ACCESS3_LOOKUP; if (IA_PROT_WGRP (prot) && (request & ACCESS3_MODIFY)) accresult |= ACCESS3_MODIFY; if (IA_PROT_WGRP (prot) && (request & ACCESS3_EXTEND)) accresult |= ACCESS3_EXTEND; /* ACCESS3_DELETE is ignored for now since that requires * knowing the permissions on the parent directory. */ if (request & ACCESS3_EXECUTE) if (IA_PROT_XGRP (prot) && (!IA_ISDIR (type))) accresult |= ACCESS3_EXECUTE; return accresult; } uint32_t nfs3_other_accessbits (ia_prot_t prot, ia_type_t type, uint32_t request) { uint32_t accresult = 0; if (IA_PROT_ROTH (prot) && (request & ACCESS3_READ)) accresult |= ACCESS3_READ; if (request & ACCESS3_LOOKUP) if (IA_ISDIR (type) && IA_PROT_ROTH (prot)) accresult |= ACCESS3_LOOKUP; if (IA_PROT_WOTH (prot) && (request & ACCESS3_MODIFY)) accresult |= ACCESS3_MODIFY; if (IA_PROT_WOTH (prot) && (request & ACCESS3_EXTEND)) accresult |= ACCESS3_EXTEND; /* ACCESS3_DELETE is ignored for now since that requires * knowing the permissions on the parent directory. */ if (request & ACCESS3_EXECUTE) if (IA_PROT_XOTH (prot) && (!IA_ISDIR (type))) accresult |= ACCESS3_EXECUTE; return accresult; } uint32_t nfs3_superuser_accessbits (ia_prot_t prot, ia_type_t type, uint32_t request) { uint32_t accresult = 0; if (request & ACCESS3_READ) accresult |= ACCESS3_READ; if (request & ACCESS3_LOOKUP) if (IA_ISDIR (type)) accresult |= ACCESS3_LOOKUP; if (request & ACCESS3_MODIFY) accresult |= ACCESS3_MODIFY; if (request & ACCESS3_EXTEND) accresult |= ACCESS3_EXTEND; /* ACCESS3_DELETE is ignored for now since that requires * knowing the permissions on the parent directory. */ if (request & ACCESS3_EXECUTE) if ((IA_PROT_XOTH (prot) || IA_PROT_XUSR (prot) || IA_PROT_XGRP (prot)) && (!IA_ISDIR (type))) accresult |= ACCESS3_EXECUTE; return accresult; } uint32_t nfs3_stat_to_accessbits (struct iatt *buf, uint32_t request, uid_t uid, gid_t gid) { uint32_t accresult = 0; ia_prot_t prot = {0, }; ia_type_t type = 0; prot = buf->ia_prot; type = buf->ia_type; if (uid == 0) accresult = nfs3_superuser_accessbits (prot, type, request); else if (buf->ia_uid == uid) accresult = nfs3_owner_accessbits (prot, type, request); else if (buf->ia_gid == gid) accresult = nfs3_group_accessbits (prot, type, request); else accresult = nfs3_other_accessbits (prot, type, request); return accresult; } void nfs3_fill_access3res (access3res *res, nfsstat3 status, struct iatt *buf, uint32_t accbits, uid_t uid, gid_t gid, uint64_t deviceid) { post_op_attr objattr; uint32_t accres = 0; memset (res, 0, sizeof (*res)); res->status = status; if (status != NFS3_OK) return; nfs3_map_deviceid_to_statdev (buf, deviceid); objattr = nfs3_stat_to_post_op_attr (buf); accres = nfs3_stat_to_accessbits (buf, accbits, uid, gid); res->access3res_u.resok.obj_attributes = objattr; res->access3res_u.resok.access = accres; } void nfs3_prep_readdir3args (readdir3args *ra, struct nfs3_fh *fh) { memset (ra, 0, sizeof (*ra)); ra->dir.data.data_val = (void *)fh; } int nfs3_is_dot_entry (char *entry) { int ret = 0; if (!entry) return 0; if (strcmp (entry, ".") == 0) ret = 1; return ret; } int nfs3_is_parentdir_entry (char *entry) { int ret = 0; if (!entry) return 0; if (strcmp (entry, "..") == 0) ret = 1; return ret; } void nfs3_funge_root_dotdot_dirent (gf_dirent_t *ent, struct nfs3_fh *dfh) { if ((!ent) || (!dfh)) return; if (nfs3_fh_is_root_fh (dfh) && nfs3_is_parentdir_entry (ent->d_name)) { ent->d_ino = 1; ent->d_stat.ia_ino = 1; } if (nfs3_fh_is_root_fh (dfh) && nfs3_is_dot_entry (ent->d_name)) { ent->d_ino = 1; ent->d_stat.ia_ino = 1; } } entry3 * nfs3_fill_entry3 (gf_dirent_t *entry, struct nfs3_fh *dfh) { entry3 *ent = NULL; if ((!entry) || (!dfh)) return NULL; ent = GF_CALLOC (1, sizeof (*ent), gf_nfs_mt_entry3); if (!ent) return NULL; gf_log (GF_NFS3, GF_LOG_TRACE, "Entry: %s", entry->d_name); /* If the entry is . or .., we need to replace the physical ino and gen * with 1 and 0 respectively if the directory is root. This funging is * needed because there is no parent directory of the root. In that * sense the behavious we provide is similar to the output of the * command: "stat /.." */ nfs3_funge_root_dotdot_dirent (entry, dfh); ent->fileid = entry->d_ino; ent->cookie = entry->d_off; ent->name = GF_CALLOC ((strlen (entry->d_name) + 1), sizeof (char), gf_nfs_mt_char); if (!ent->name) { GF_FREE (ent); ent = NULL; goto err; } strcpy (ent->name, entry->d_name); err: return ent; } void nfs3_fill_post_op_fh3 (struct nfs3_fh *fh, post_op_fh3 *pfh) { uint32_t fhlen = 0; if ((!fh) || (!pfh)) return; pfh->handle_follows = 1; fhlen = nfs3_fh_compute_size (fh); pfh->post_op_fh3_u.handle.data.data_val = (void *)fh; pfh->post_op_fh3_u.handle.data.data_len = fhlen; } post_op_fh3 nfs3_fh_to_post_op_fh3 (struct nfs3_fh *fh) { post_op_fh3 pfh = {0, }; char *fhp = NULL; if (!fh) return pfh; pfh.handle_follows = 1; fhp = GF_CALLOC (1, sizeof (*fh), gf_nfs_mt_char); if (!fhp) return pfh; memcpy (fhp, fh, sizeof (*fh)); nfs3_fill_post_op_fh3 ((struct nfs3_fh *)fhp, &pfh); return pfh; } entryp3 * nfs3_fill_entryp3 (gf_dirent_t *entry, struct nfs3_fh *dirfh, uint64_t devid) { entryp3 *ent = NULL; struct nfs3_fh newfh = {{0}, }; if ((!entry) || (!dirfh)) return NULL; /* If the entry is . or .., we need to replace the physical ino and gen * with 1 and 0 respectively if the directory is root. This funging is * needed because there is no parent directory of the root. In that * sense the behavious we provide is similar to the output of the * command: "stat /.." */ nfs3_funge_root_dotdot_dirent (entry, dirfh); gf_log (GF_NFS3, GF_LOG_TRACE, "Entry: %s, ino: %"PRIu64, entry->d_name, entry->d_ino); ent = GF_CALLOC (1, sizeof (*ent), gf_nfs_mt_entryp3); if (!ent) return NULL; ent->fileid = entry->d_ino; ent->cookie = entry->d_off; ent->name = GF_CALLOC ((strlen (entry->d_name) + 1), sizeof (char), gf_nfs_mt_char); if (!ent->name) { GF_FREE (ent); ent = NULL; goto err; } strcpy (ent->name, entry->d_name); nfs3_fh_build_child_fh (dirfh, &entry->d_stat, &newfh); nfs3_map_deviceid_to_statdev (&entry->d_stat, devid); ent->name_attributes = nfs3_stat_to_post_op_attr (&entry->d_stat); ent->name_handle = nfs3_fh_to_post_op_fh3 (&newfh); err: return ent; } void nfs3_fill_readdir3res (readdir3res *res, nfsstat3 stat, struct nfs3_fh *dirfh, uint64_t cverf, struct iatt *dirstat, gf_dirent_t *entries, count3 count, int is_eof, uint64_t deviceid) { post_op_attr dirattr; entry3 *ent = NULL; entry3 *headentry = NULL; entry3 *preventry = NULL; count3 filled = 0; gf_dirent_t *listhead = NULL; memset (res, 0, sizeof (*res)); res->status = stat; if (stat != NFS3_OK) return; nfs3_map_deviceid_to_statdev (dirstat, deviceid); dirattr = nfs3_stat_to_post_op_attr (dirstat); res->readdir3res_u.resok.dir_attributes = dirattr; res->readdir3res_u.resok.reply.eof = (bool_t)is_eof; memcpy (res->readdir3res_u.resok.cookieverf, &cverf, sizeof (cverf)); filled = NFS3_READDIR_RESOK_SIZE; /* First entry is just the list head */ listhead = entries; entries = entries->next; while (((entries) && (entries != listhead)) && (filled < count)) { /* if ((strcmp (entries->d_name, ".") == 0) || (strcmp (entries->d_name, "..") == 0)) goto nextentry; */ ent = nfs3_fill_entry3 (entries, dirfh); if (!ent) break; if (!headentry) headentry = ent; if (preventry) { preventry->nextentry = ent; preventry = ent; } else preventry = ent; filled += NFS3_ENTRY3_FIXED_SIZE + strlen (ent->name); //nextentry: entries = entries->next; } res->readdir3res_u.resok.reply.entries = headentry; return; } void nfs3_fill_readdirp3res (readdirp3res *res, nfsstat3 stat, struct nfs3_fh *dirfh, uint64_t cverf, struct iatt *dirstat, gf_dirent_t *entries, count3 dircount, count3 maxcount, int is_eof, uint64_t deviceid) { post_op_attr dirattr; entryp3 *ent = NULL; entryp3 *headentry = NULL; entryp3 *preventry = NULL; count3 filled = 0; gf_dirent_t *listhead = NULL; int fhlen = 0; memset (res, 0, sizeof (*res)); res->status = stat; if (stat != NFS3_OK) return; nfs3_map_deviceid_to_statdev (dirstat, deviceid); dirattr = nfs3_stat_to_post_op_attr (dirstat); res->readdirp3res_u.resok.dir_attributes = dirattr; res->readdirp3res_u.resok.reply.eof = (bool_t)is_eof; memcpy (res->readdirp3res_u.resok.cookieverf, &cverf, sizeof (cverf)); filled = NFS3_READDIR_RESOK_SIZE; /* First entry is just the list head */ listhead = entries; entries = entries->next; while (((entries) && (entries != listhead)) && (filled < maxcount)) { /* Linux does not display . and .. entries unless we p