MFC r283601:

Add V_MNTREF flag, to indicate that caller of vn_start*_write() already
owns a reference on the mount point, and the functions can consume it.
This commit is contained in:
kib 2015-06-10 02:20:58 +00:00
parent a105f5d7fd
commit 2187b2a06e
2 changed files with 11 additions and 10 deletions

View File

@ -1619,14 +1619,14 @@ vn_start_write_locked(struct mount *mp, int flags)
}
int
vn_start_write(vp, mpp, flags)
struct vnode *vp;
struct mount **mpp;
int flags;
vn_start_write(struct vnode *vp, struct mount **mpp, int flags)
{
struct mount *mp;
int error;
KASSERT((flags & V_MNTREF) == 0 || (*mpp != NULL && vp == NULL),
("V_MNTREF requires mp"));
error = 0;
/*
* If a vnode is provided, get and return the mount point that
@ -1651,7 +1651,7 @@ vn_start_write(vp, mpp, flags)
* emulate a vfs_ref().
*/
MNT_ILOCK(mp);
if (vp == NULL)
if (vp == NULL && (flags & V_MNTREF) == 0)
MNT_REF(mp);
return (vn_start_write_locked(mp, flags));
@ -1665,14 +1665,14 @@ vn_start_write(vp, mpp, flags)
* time, these operations are halted until the suspension is over.
*/
int
vn_start_secondary_write(vp, mpp, flags)
struct vnode *vp;
struct mount **mpp;
int flags;
vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags)
{
struct mount *mp;
int error;
KASSERT((flags & V_MNTREF) == 0 || (*mpp != NULL && vp == NULL),
("V_MNTREF requires mp"));
retry:
if (vp != NULL) {
if ((error = VOP_GETWRITEMOUNT(vp, mpp)) != 0) {
@ -1697,7 +1697,7 @@ vn_start_secondary_write(vp, mpp, flags)
* emulate a vfs_ref().
*/
MNT_ILOCK(mp);
if (vp == NULL)
if (vp == NULL && (flags & V_MNTREF) == 0)
MNT_REF(mp);
if ((mp->mnt_kern_flag & (MNTK_SUSPENDED | MNTK_SUSPEND2)) == 0) {
mp->mnt_secondary_writes++;

View File

@ -395,6 +395,7 @@ extern int vttoif_tab[];
#define V_WAIT 0x0001 /* vn_start_write: sleep for suspend */
#define V_NOWAIT 0x0002 /* vn_start_write: don't sleep for suspend */
#define V_XSLEEP 0x0004 /* vn_start_write: just return after sleep */
#define V_MNTREF 0x0010 /* vn_start_write: mp is already ref-ed */
#define VR_START_WRITE 0x0001 /* vfs_write_resume: start write atomically */
#define VR_NO_SUSPCLR 0x0002 /* vfs_write_resume: do not clear suspension */