Skip to content

Commit

Permalink
Disable unused pathname::pn_path* (unneeded in Linux)
Browse files Browse the repository at this point in the history
struct pathname is originally from Solaris VFS, and it has been used
in ZoL to merely call VOP from Linux VFS interface without API change,
therefore pathname::pn_path* are unused and unneeded. Technically,
struct pathname is a wrapper for C string in ZoL.

Saves stack a bit on lookup and unlink.

(#if0'd members instead of removing since comments refer to them.)

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Richard Elling <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Signed-off-by: Tomohiro Kusumi <[email protected]>
Closes #9025
  • Loading branch information
kusumi authored and tonyhutter committed Sep 25, 2019
1 parent cf966cb commit 0a22324
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions include/sys/pathname.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ extern "C" {
*/
typedef struct pathname {
char *pn_buf; /* underlying storage */
#if 0 /* unused in ZoL */
char *pn_path; /* remaining pathname */
size_t pn_pathlen; /* remaining length */
#endif
size_t pn_bufsize; /* total size of pn_buf */
} pathname_t;

Expand Down
15 changes: 11 additions & 4 deletions module/zfs/pathname.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ pn_alloc(struct pathname *pnp)
void
pn_alloc_sz(struct pathname *pnp, size_t sz)
{
pnp->pn_path = pnp->pn_buf = kmem_alloc(sz, KM_SLEEP);
pnp->pn_pathlen = 0;
pnp->pn_buf = kmem_alloc(sz, KM_SLEEP);
pnp->pn_bufsize = sz;
#if 0 /* unused in ZoL */
pnp->pn_path = pnp->pn_buf;
pnp->pn_pathlen = 0;
#endif
}

/*
Expand All @@ -84,6 +87,10 @@ pn_free(struct pathname *pnp)
{
/* pn_bufsize is usually MAXPATHLEN, but may not be */
kmem_free(pnp->pn_buf, pnp->pn_bufsize);
pnp->pn_path = pnp->pn_buf = NULL;
pnp->pn_pathlen = pnp->pn_bufsize = 0;
pnp->pn_buf = NULL;
pnp->pn_bufsize = 0;
#if 0 /* unused in ZoL */
pnp->pn_path = NULL;
pnp->pn_pathlen = 0;
#endif
}

0 comments on commit 0a22324

Please sign in to comment.