Messages in this thread Patch in this message | | | Subject | [RFC][PATCH] Support for preadv()/pwritev() | From | Badari Pulavarty <> | Date | Fri, 09 Dec 2005 13:11:04 -0800 |
| |
Hi,
Some of the database folks are looking going towards "threaded" database model and wants support for preadv() and pwritev() - so that they have a way of doing lseek() followed by readv/writev() in the thread-safe way.
Here is the patch I cooked up and looking for feedback. I really don't like adding new syscalls for this, but I don't see a way out.
Of course, database folks want aio_readv/aio_writev() support also, which Zack is working on.
Comments ? Suggestions ?
Thanks, Badari
diff -Narup -X dontdiff linux-2.6.15-rc5/arch/i386/kernel/syscall_table.S linux-2.6.15-rc5.preadv/arch/i386/kernel/syscall_table.S --- linux-2.6.15-rc5/arch/i386/kernel/syscall_table.S 2005-12-03 21:10:42.000000000 -0800 +++ linux-2.6.15-rc5.preadv/arch/i386/kernel/syscall_table.S 2005-12-09 08:01:22.465116256 -0800 @@ -294,3 +294,5 @@ ENTRY(sys_call_table) .long sys_inotify_init .long sys_inotify_add_watch .long sys_inotify_rm_watch + .long sys_preadv + .long sys_pwritev diff -Narup -X dontdiff linux-2.6.15-rc5/fs/read_write.c linux-2.6.15-rc5.preadv/fs/read_write.c --- linux-2.6.15-rc5/fs/read_write.c 2005-12-03 21:10:42.000000000 -0800 +++ linux-2.6.15-rc5.preadv/fs/read_write.c 2005-12-09 08:02:43.590783280 -0800 @@ -622,6 +622,46 @@ sys_writev(unsigned long fd, const struc return ret; } +asmlinkage ssize_t sys_preadv(unsigned int fd, const struct iovec __user *vec, + unsigned long vlen, loff_t pos) +{ + struct file *file; + ssize_t ret = -EBADF; + int fput_needed; + + if (pos < 0) + return -EINVAL; + + file = fget_light(fd, &fput_needed); + if (file) { + ret = -ESPIPE; + if (file->f_mode & FMODE_PREAD) + ret = vfs_readv(file, vec, vlen, &pos); + fput_light(file, fput_needed); + } + return ret; +} + +asmlinkage ssize_t sys_pwritev(unsigned int fd, const struct iovec __user *vec, + unsigned long vlen, loff_t pos) +{ + struct file *file; + ssize_t ret = -EBADF; + int fput_needed; + + if (pos < 0) + return -EINVAL; + + file = fget_light(fd, &fput_needed); + if (file) { + ret = -ESPIPE; + if (file->f_mode & FMODE_PWRITE) + ret = vfs_writev(file, vec, vlen, &pos); + fput_light(file, fput_needed); + } + return ret; +} + static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, size_t count, loff_t max) { | |