Hi,
In August 2019 I tried to unlock lseek(2) which failed since the vnode
lock could not be acquired without holding the kernel lock back then,
found the hard way. claudio@ recently[1] make it possible to acquire a
vnode lock without holding the kernel lock. I therefore would like to
give this another try. The kernel lock is still required around
VOP_GETATTR() as the underlying file system implementations are not
yet^W MP-safe.

Comments? OK?

[1] 
https://github.com/openbsd/src/commit/9d6122f62b6ed32d6c956e1d5269114b2f24ea14

Index: kern/syscalls.master
===================================================================
RCS file: /cvs/src/sys/kern/syscalls.master,v
retrieving revision 1.209
diff -u -p -r1.209 syscalls.master
--- kern/syscalls.master        18 Mar 2021 08:43:38 -0000      1.209
+++ kern/syscalls.master        29 Apr 2021 19:09:58 -0000
@@ -349,7 +349,7 @@
 197    STD             { void *sys_mmap(void *addr, size_t len, int prot, \
                            int flags, int fd, long pad, off_t pos); }
 198    INDIR           { quad_t sys___syscall(quad_t num, ...); }
-199    STD             { off_t sys_lseek(int fd, int pad, off_t offset, \
+199    STD NOLOCK      { off_t sys_lseek(int fd, int pad, off_t offset, \
                            int whence); }
 200    STD             { int sys_truncate(const char *path, int pad, \
                            off_t length); }
Index: kern/vfs_vnops.c
===================================================================
RCS file: /cvs/src/sys/kern/vfs_vnops.c,v
retrieving revision 1.115
diff -u -p -r1.115 vfs_vnops.c
--- kern/vfs_vnops.c    28 Apr 2021 09:53:53 -0000      1.115
+++ kern/vfs_vnops.c    29 Apr 2021 19:09:58 -0000
@@ -657,7 +657,9 @@ vn_seek(struct file *fp, off_t *offset, 
                newoff = fp->f_offset + *offset;
                break;
        case SEEK_END:
+               KERNEL_LOCK();
                error = VOP_GETATTR(vp, &vattr, cred, p);
+               KERNEL_UNLOCK();
                if (error)
                        goto out;
                newoff = *offset + (off_t)vattr.va_size;

Reply via email to