tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: DIOCDISCARD, fdiscard, and fallocate



On 24 Mar 2014, at 05:01, David Holland <dholland-tech%netbsd.org@localhost> 
wrote:

> ok, I have preliminary patches that kill off DIOCDISCARD and
> DIOCGDISCARDPARAMS in favor of a fdiscard system call (meant to work
> on both files and devices) and add that and also a fallocate system
> call.
> 
> http://www.netbsd.org/~dholland/tmp/discard/
> (includes both the 17-part split patch and a combined patch)

> +.\" XXX: if you discard part of a block in a regular file, should that
> +.\" part be explicitly zeroed? Also, how do you find the underlying
> +.\" block size?

For regular files the discarded extent should read back as zeroes
so if we discard part of a block this part should be zeroed.
This is the least surprise for the user of this interface.

What happens for file systems not supporting holes?
Return an error or zero the extent?

> +spec_fdiscard(void *v)
...
> +       /* XXX: gross. Is this what we want and is it safe enough? blah */
> +       VOP_UNLOCK(vp);
> +       mutex_enter(vp->v_interlock);
> +       if ((vp->v_iflag & VI_XLOCK) == 0 && vp->v_specnode != NULL) {
> +               dev = vp->v_rdev;
> +       }
> +       mutex_exit(vp->v_interlock);
> +       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);

This will now be:

        if (vdead_check(vp, VDEAD_NOWAIT) == 0 && vp->v_specnode != NULL)

There is no need to unlock/relock the vnode here.

--
J. Hannken-Illjes - hannken%eis.cs.tu-bs.de@localhost - TU Braunschweig 
(Germany)



Home | Main Index | Thread Index | Old Index