vfs: short-circuit the common case NDFREE calls
Almost all consumers use the NDF_ONLY_PNBUF macro, making them avoidably branch a lot in the NDFREE routine. Also note most of them should not need to call any cleanup anyway as they don't request HASBUF.
This commit is contained in:
parent
404927357d
commit
b1f910e02c
@ -1390,7 +1390,17 @@ NDINIT_ALL(struct nameidata *ndp, u_long op, u_long flags, enum uio_seg segflg,
|
||||
* Free data allocated by namei(); see namei(9) for details.
|
||||
*/
|
||||
void
|
||||
NDFREE(struct nameidata *ndp, const u_int flags)
|
||||
NDFREE_PNBUF(struct nameidata *ndp)
|
||||
{
|
||||
|
||||
if ((ndp->ni_cnd.cn_flags & HASBUF) != 0) {
|
||||
uma_zfree(namei_zone, ndp->ni_cnd.cn_pnbuf);
|
||||
ndp->ni_cnd.cn_flags &= ~HASBUF;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
(NDFREE)(struct nameidata *ndp, const u_int flags)
|
||||
{
|
||||
int unlock_dvp;
|
||||
int unlock_vp;
|
||||
@ -1398,10 +1408,8 @@ NDFREE(struct nameidata *ndp, const u_int flags)
|
||||
unlock_dvp = 0;
|
||||
unlock_vp = 0;
|
||||
|
||||
if (!(flags & NDF_NO_FREE_PNBUF) &&
|
||||
(ndp->ni_cnd.cn_flags & HASBUF)) {
|
||||
uma_zfree(namei_zone, ndp->ni_cnd.cn_pnbuf);
|
||||
ndp->ni_cnd.cn_flags &= ~HASBUF;
|
||||
if (!(flags & NDF_NO_FREE_PNBUF)) {
|
||||
NDFREE_PNBUF(ndp);
|
||||
}
|
||||
if (!(flags & NDF_NO_VP_UNLOCK) &&
|
||||
(ndp->ni_cnd.cn_flags & LOCKLEAF) && ndp->ni_vp)
|
||||
|
@ -210,7 +210,15 @@ void NDINIT_ALL(struct nameidata *ndp, u_long op, u_long flags,
|
||||
#define NDF_NO_FREE_PNBUF 0x00000020
|
||||
#define NDF_ONLY_PNBUF (~NDF_NO_FREE_PNBUF)
|
||||
|
||||
void NDFREE_PNBUF(struct nameidata *);
|
||||
void NDFREE(struct nameidata *, const u_int);
|
||||
#define NDFREE(ndp, flags) do { \
|
||||
struct nameidata *_ndp = (ndp); \
|
||||
if (__builtin_constant_p(flags) && flags == NDF_ONLY_PNBUF) \
|
||||
NDFREE_PNBUF(_ndp); \
|
||||
else \
|
||||
NDFREE(_ndp, flags); \
|
||||
} while (0)
|
||||
|
||||
int namei(struct nameidata *ndp);
|
||||
int lookup(struct nameidata *ndp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user