* [RFC][PATCH] Support for preadv()/pwritev()
@ 2005-12-09 21:11 Badari Pulavarty
0 siblings, 0 replies; only message in thread
From: Badari Pulavarty @ 2005-12-09 21:11 UTC (permalink / raw)
To: lkml, linux-fsdevel; +Cc: Zach Brown, Christoph Hellwig, akpm
[-- Attachment #1: Type: text/plain, Size: 498 bytes --]
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
[-- Attachment #2: preadv-pwritev.patch --]
[-- Type: text/x-patch, Size: 1786 bytes --]
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)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-12-09 21:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-09 21:11 [RFC][PATCH] Support for preadv()/pwritev() Badari Pulavarty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).