diff options
| -rw-r--r-- | xlators/nfs/server/src/nfs3-helpers.c | 236 | 
1 files changed, 0 insertions, 236 deletions
diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c index 68ec8e97005..e2c16ef0e95 100644 --- a/xlators/nfs/server/src/nfs3-helpers.c +++ b/xlators/nfs/server/src/nfs3-helpers.c @@ -3545,55 +3545,6 @@ err:          return ret;  } -#define GF_NFS3_FHRESOLVE_FOUND         1 -#define GF_NFS3_FHRESOLVE_NOTFOUND      2 -#define GF_NFS3_FHRESOLVE_DIRFOUND      3 - -int -nfs3_fh_resolve_check_entry (struct nfs3_fh *fh, gf_dirent_t *candidate, -                             int hashidx) -{ -        struct iatt             *ia = NULL; -        int                     ret = GF_NFS3_FHRESOLVE_NOTFOUND; -        nfs3_hash_entry_t       entryhash = 0; - -        if ((!fh) || (!candidate)) -                return ret; - -        if ((strcmp (candidate->d_name, ".") == 0) || -            (strcmp (candidate->d_name, "..") == 0)) -                goto found_entry; - -        ia = &candidate->d_stat; -        if ((uuid_compare (candidate->d_stat.ia_gfid, fh->gfid)) == 0) { -                gf_log (GF_NFS3, GF_LOG_TRACE, "Found entry: gfid: %s, " -                        "name: %s, hashcount %d", -                         uuid_utoa (candidate->d_stat.ia_gfid), -                         candidate->d_name, hashidx); -                ret = GF_NFS3_FHRESOLVE_FOUND; -                goto found_entry; -        } - -        /* This condition ensures that we never have to be afraid of having -         * a directory hash conflict with a file hash. The consequence of -         * this condition is that we can now have unlimited files in a directory -         * and upto 65536 sub-directories in a directory. -         */ -        if (!IA_ISDIR (candidate->d_stat.ia_type)) -                goto found_entry; -        entryhash = fh->entryhash[hashidx]; -        if (entryhash == nfs3_fh_hash_entry (ia->ia_gfid)) { -                gf_log (GF_NFS3, GF_LOG_TRACE, "Found hash match: %s: %d, " -                        "hashidx: %d", candidate->d_name, entryhash, hashidx); -                ret = GF_NFS3_FHRESOLVE_DIRFOUND; -                goto found_entry; -        } - -found_entry: - -        return ret; -} -  int32_t  nfs3_fh_resolve_entry_lookup_cbk (call_frame_t *frame, void *cookie, @@ -3632,119 +3583,6 @@ err:  } -int -nfs3_fh_resolve_found_entry (nfs3_call_state_t *cs, gf_dirent_t *candidate) -{ -        int             ret = 0; -        nfs_user_t      nfu = {0, }; -        uuid_t          gfid = {0, }; - -        if ((!cs) || (!candidate)) -                return -EFAULT; - -        uuid_copy (gfid, cs->resolvedloc.inode->gfid); -        nfs_loc_wipe (&cs->resolvedloc); -        ret = nfs_entry_loc_fill (cs->vol->itable, gfid, candidate->d_name, -                                  &cs->resolvedloc, NFS_RESOLVE_CREATE); -        if (ret == -ENOENT) { -                gf_log (GF_NFS3, GF_LOG_TRACE, "Entry not in itable, needs" -                        " lookup"); -                nfs_user_root_create (&nfu); -                ret = nfs_lookup (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc, -                                  nfs3_fh_resolve_entry_lookup_cbk, -                                  cs); -        } else { -                gf_log (GF_NFS3, GF_LOG_TRACE, "Entry got from itable"); -                nfs3_call_resume (cs); -        } - -        return ret; -} - - -int32_t -nfs3_fh_resolve_parent_lookup_cbk (call_frame_t *frame, void *cookie, -                                  xlator_t *this, int32_t op_ret, -                                  int32_t op_errno, inode_t *inode, -                                  struct iatt *buf, dict_t *xattr, -                                  struct iatt *postparent) -{ -        nfs3_call_state_t       *cs = NULL; -        inode_t                 *linked_inode = NULL; - -        cs = frame->local; -        cs->resolve_ret = op_ret; -        cs->resolve_errno = op_errno; - -        if (op_ret == -1) { -                gf_log (GF_NFS3, (op_errno == ENOENT ? GF_LOG_TRACE : GF_LOG_ERROR), -                        "Lookup failed: %s: %s", -                        cs->resolvedloc.path, strerror (op_errno)); -                nfs3_call_resume (cs); -                goto err; -        } else -                gf_log (GF_NFS3, GF_LOG_TRACE, "Entry looked up: %s", -                        cs->resolvedloc.path); - -        linked_inode = inode_link (inode, cs->resolvedloc.parent, -                                   cs->resolvedloc.name, buf); -        if (linked_inode) { -                inode_lookup (linked_inode); -                inode_unref (linked_inode); -        } -        nfs3_fh_resolve_entry_hard (cs); - -err: -        return 0; -} - - -int -nfs3_fh_resolve_found_parent (nfs3_call_state_t *cs, gf_dirent_t *candidate) -{ -        int             ret = 0; -        nfs_user_t      nfu = {0, }; -        uuid_t          gfid = {0, }; - -        if ((!cs) || (!candidate)) -                return -EFAULT; - -        uuid_copy (gfid, cs->resolvedloc.inode->gfid); -        nfs_loc_wipe (&cs->resolvedloc); -        ret = nfs_entry_loc_fill (cs->vol->itable, gfid, candidate->d_name, -                                  &cs->resolvedloc, NFS_RESOLVE_CREATE); -        if (ret == -ENOENT) { -                nfs_user_root_create (&nfu); -                ret = nfs_lookup (cs->nfsx, cs->vol, &nfu, &cs->resolvedloc, -                                  nfs3_fh_resolve_parent_lookup_cbk, -                                  cs); -        } else -                nfs3_fh_resolve_entry_hard (cs); - -        return ret; -} - - -int -nfs3_fh_resolve_found (nfs3_call_state_t *cs, gf_dirent_t *candidate) -{ -        int             ret = 0; - -        if ((!cs) || (!candidate)) -                return -EFAULT; - -        if (!cs->resolventry) { -                gf_log (GF_NFS3, GF_LOG_TRACE, "Candidate entry was found"); -                ret = nfs3_fh_resolve_found_entry (cs, candidate); -        } else { -                gf_log (GF_NFS3, GF_LOG_TRACE, "Entry's parent was found"); -                ret = nfs3_fh_resolve_found_parent (cs, candidate); -        } - -        return ret; -} - -  int32_t  nfs3_fh_resolve_inode_lookup_cbk (call_frame_t *frame, void *cookie,                                    xlator_t *this, int32_t op_ret, @@ -3791,80 +3629,6 @@ err:  } -/* Validate the depth of the dir such that we do not end up opening and - * reading directories beyond those that are needed for resolving the file - * handle. - * Returns 1 if fh resolution can continue, 0 otherwise. - */ -int -nfs3_fh_resolve_validate_dirdepth (nfs3_call_state_t *cs) -{ -        int     ret = 1; - -        if (!cs) -                return 0; - -        /* This condition will generally never be hit because the -         * hash-matching scheme will prevent us from going into a -         * directory that is not part of the hash-array. -         */ -        if (nfs3_fh_hash_index_is_beyond (&cs->resolvefh, cs->hashidx)) { -                gf_log (GF_NFS3, GF_LOG_TRACE, "Hash index is beyond: idx %d," -                        " fh idx: %d", cs->hashidx, cs->resolvefh.hashcount); -                ret = 0; -                goto out; -        } - -        if (cs->hashidx >= GF_NFSFH_MAXHASHES) { -                gf_log (GF_NFS3, GF_LOG_TRACE, "Hash index beyond max hashes:" -                        " hashidx %d, max: %d", cs->hashidx, -                        GF_NFSFH_MAXHASHES); -                ret = 0; -                goto out; -        } - -out: -        return ret; -} - - -/* - * Called in a recursive code path, so if another - * directory was opened in an earlier call during fh resolution, we must unref - * through this reference before opening another fd_t. - */ -#define nfs3_fh_resolve_close_cwd(cst)                                  \ -        do {                                                            \ -                if ((cst)->resolve_dir_fd) {                            \ -                        gf_log (GF_NFS3, GF_LOG_TRACE, "resolve fd "    \ -                                "unrefing: 0x%lx, ref: %d",             \ -                                (long)(cst)->resolve_dir_fd,            \ -                                (cst)->resolve_dir_fd->refcount);       \ -                                fd_unref ((cst)->resolve_dir_fd);       \ -                }                                                       \ -        } while (0)                                                     \ - - -int -nfs3_fh_resolve_determine_response (nfs3_call_state_t *cs) { - -        int     response = GF_NFS3_FHRESOLVE_NOTFOUND; - -        if (!cs) -                return response; - -        if ((cs->hashmatch) && (cs->entrymatch)) -                response = GF_NFS3_FHRESOLVE_FOUND; -        else if ((cs->hashmatch) && (!cs->entrymatch)) -                response = GF_NFS3_FHRESOLVE_DIRFOUND; -        else if ((!cs->hashmatch) && (cs->entrymatch)) -                response = GF_NFS3_FHRESOLVE_FOUND; -        else if ((!cs->hashmatch) && (!cs->entrymatch)) -                response = GF_NFS3_FHRESOLVE_NOTFOUND; - -        return response; -} -  /* Needs no extra argument since it knows that the fh to be resolved is in   * resolvefh and that it needs to start looking from the root.  | 
