tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[PATCH] fallocate() for FFS
Implementing fallocate for FFS seems quite obvious. Is there anything I
missed in the patch below? Is it good enough to commit?
This lets me discover that posix_fallocate() libc stub is buggy. Using
it through #include <unistd.h> leads argument corruption. Defining it as
int posix_fallocate(int, int, off_t, off_t); let it work (note the
second int pad, as in syscalls.master). I guess we need to add a libc
stub too.
Index: sys/ufs/ffs/ffs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_vnops.c,v
retrieving revision 1.125
diff -U 4 -r1.125 ffs_vnops.c
--- sys/ufs/ffs/ffs_vnops.c 25 Jul 2014 08:20:53 -0000 1.125
+++ sys/ufs/ffs/ffs_vnops.c 25 Sep 2014 01:09:50 -0000
@@ -114,9 +114,9 @@
{ &vop_getattr_desc, ufs_getattr }, /* getattr */
{ &vop_setattr_desc, ufs_setattr }, /* setattr */
{ &vop_read_desc, ffs_read }, /* read */
{ &vop_write_desc, ffs_write }, /* write */
- { &vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */
+ { &vop_fallocate_desc, ffs_fallocate }, /* fallocate */
{ &vop_fdiscard_desc, genfs_eopnotsupp }, /* fdiscard */
{ &vop_ioctl_desc, ufs_ioctl }, /* ioctl */
{ &vop_fcntl_desc, ufs_fcntl }, /* fcntl */
{ &vop_poll_desc, ufs_poll }, /* poll */
@@ -326,8 +326,41 @@
return error;
}
int
+ffs_fallocate(void *v)
+{
+ struct vop_fallocate_args /* {
+ struct vnode *a_vp;
+ off_t a_pos;
+ off_t a_len;
+ } */ *ap = v;
+ struct vnode *vp;
+ struct mount *mp;
+ int error;
+
+
+ vp = ap->a_vp;
+ mp = vp->v_mount;
+
+ fstrans_start(mp, FSTRANS_LAZY);
+ error = UFS_WAPBL_BEGIN(vp->v_mount);
+ if (error)
+ goto out;
+
+ genfs_node_wrlock(vp);
+ error = GOP_ALLOC(vp, ap->a_pos, ap->a_len, 0, curlwp->l_cred);
+ genfs_node_unlock(vp);
+
+ UFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
+ UFS_WAPBL_END(vp->v_mount);
+out:
+ fstrans_done(mp);
+
+ return error;
+}
+
+int
ffs_fsync(void *v)
{
struct vop_fsync_args /* {
struct vnode *a_vp;
--
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index