tech-kern archive

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

Re: [PATCH] GOP_ALLOC and fallocate for PUFFS



J. Hannken-Illjes <hannken%eis.cs.tu-bs.de@localhost> wrote:

> Ok -- if you want to use it, you have to implement it on the client side
> as puffs has no idea how to allocate blocks -- right?

Here is my GOP_ALLOC so far. If available, use fallocate, otherwise
write zeroes. puffs_vnop_write() was split into puffs_vnop_write_cache()
and puffs_vnop_write_fs()

int
puffs_gop_alloc(struct vnode *vp, off_t off, off_t len,
                int flags, kauth_cred_t cred)
{
        struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
        int uflags = 0;
        void *zbuf;
        struct iovec iov;
        struct uio uio;
        int error;

        if (EXISTSOP(pmp, FALLOCATE)) {
                error = _puffs_vnop_fallocate(vp, off, len);
                goto out;
        }

        zbuf = kmem_alloc(len, KM_SLEEP);
 
        iov.iov_base = zbuf;
        iov.iov_len = len;
 
        UIO_SETUP_SYSSPACE(&uio);
        uio.uio_iov = &iov;
        uio.uio_iovcnt = 1;
        uio.uio_offset = off;
        uio.uio_resid = len;
        uio.uio_rw = UIO_WRITE;
 
        error = _puffs_vnop_write_fs(vp, &uio, IO_SYNC, cred, &uflags);
        if (error == 0)
                puffs_updatenode(VPTOPP(vp), uflags, vp->v_size);
 
        kmem_free(zbuf, len);
 
out:
        return error;
}

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index