diff options
| author | Mohit Agrawal <moagrawal@redhat.com> | 2019-10-28 21:53:01 +0530 |
|---|---|---|
| committer | Atin Mukherjee <amukherj@redhat.com> | 2019-11-18 01:14:18 +0000 |
| commit | cd1872ae49d7bc83403fce6821c102edc4e97796 (patch) | |
| tree | 0d662f26ab042cdfbad0bf6051cbe70777cf2863 /xlators/storage/posix/src/posix-inode-fd-ops.c | |
| parent | 515d1b4577d989fa99f236d9e344a71db7d001a0 (diff) | |
posix: Improve MAKE_HANDLE_PATH
Pass the maximum buffer (PATH_MAX) to posix_handle_path to
avoid the posix_handle_path call again.
Change-Id: I7d18313870218dc028c5f7fc94d6ec85a2bdb332
Updates #761
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-inode-fd-ops.c')
| -rw-r--r-- | xlators/storage/posix/src/posix-inode-fd-ops.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c index 56f8d344640..17c2fe4fab4 100644 --- a/xlators/storage/posix/src/posix-inode-fd-ops.c +++ b/xlators/storage/posix/src/posix-inode-fd-ops.c @@ -5297,20 +5297,13 @@ posix_fill_readdir(fd_t *fd, DIR *dir, off_t off, size_t size, } if (skip_dirs) { - len = posix_handle_path(this, fd->inode->gfid, NULL, NULL, 0); + hpath = alloca(PATH_MAX); + len = posix_handle_path(this, fd->inode->gfid, NULL, hpath, PATH_MAX); if (len <= 0) { errno = ESTALE; count = -1; goto out; } - hpath = alloca(len + 256); /* NAME_MAX */ - - if (posix_handle_path(this, fd->inode->gfid, NULL, hpath, len) <= 0) { - errno = ESTALE; - count = -1; - goto out; - } - len = strlen(hpath); hpath[len] = '/'; } @@ -5478,22 +5471,14 @@ posix_readdirp_fill(xlator_t *this, fd_t *fd, gf_dirent_t *entries, itable = fd->inode->table; - len = posix_handle_path(this, fd->inode->gfid, NULL, NULL, 0); + hpath = alloca(PATH_MAX); + len = posix_handle_path(this, fd->inode->gfid, NULL, hpath, PATH_MAX); if (len <= 0) { gf_msg(this->name, GF_LOG_WARNING, 0, P_MSG_HANDLEPATH_FAILED, "Failed to create handle path, fd=%p, gfid=%s", fd, uuid_utoa(fd->inode->gfid)); return -1; } - - hpath = alloca(len + 256); /* NAME_MAX */ - if (posix_handle_path(this, fd->inode->gfid, NULL, hpath, len) <= 0) { - gf_msg(this->name, GF_LOG_WARNING, 0, P_MSG_HANDLEPATH_FAILED, - "Failed to create handle path, fd=%p, gfid=%s", fd, - uuid_utoa(fd->inode->gfid)); - return -1; - } - len = strlen(hpath); hpath[len] = '/'; |
