* Re: [RFC PATCH 0/2] dirreadahead system call
[not found] <1406309851-10628-1-git-send-email-adas@redhat.com>
@ 2014-07-29 8:19 ` Michael Kerrisk
[not found] ` <1406309851-10628-2-git-send-email-adas@redhat.com>
1 sibling, 0 replies; 3+ messages in thread
From: Michael Kerrisk @ 2014-07-29 8:19 UTC (permalink / raw)
To: Abhi Das; +Cc: Linux Kernel, Linux-Fsdevel, cluster-devel, Linux API
On Fri, Jul 25, 2014 at 7:37 PM, Abhi Das <adas@redhat.com> wrote:
> This system call takes 3 arguments:
> fd - file descriptor of the directory being readahead
> *offset - offset in dir from which to resume. This is updated
> as we move along in the directory
> count - The max number of entries to readahead
>
> The syscall is supposed to read upto 'count' entries starting at
> '*offset' and cache the inodes corresponding to those entries. It
> returns a negative error code or a positive number indicating
> the number of inodes it has issued readaheads for. It also
> updates the '*offset' value so that repeated calls to dirreadahead
> can resume at the right location. Returns 0 when there are no more
> entries left.
Hello Abhi,
As per Documentation/SubmitChecklist, please CC linux-api on patches
that change the kerne-user-space API/ABI. (See
https://www.kernel.org/doc/man-pages/linux-api-ml.html for more
details.)
Cheers,
Michael
> Abhi Das (2):
> fs: Add dirreadahead syscall and VFS hooks
> gfs2: GFS2's implementation of the dir_readahead file operation
>
> arch/x86/syscalls/syscall_32.tbl | 1 +
> arch/x86/syscalls/syscall_64.tbl | 1 +
> fs/gfs2/Makefile | 3 +-
> fs/gfs2/dir.c | 49 ++++++---
> fs/gfs2/dir.h | 15 +++
> fs/gfs2/dir_readahead.c | 209 +++++++++++++++++++++++++++++++++++++++
> fs/gfs2/file.c | 2 +
> fs/gfs2/main.c | 10 +-
> fs/gfs2/super.c | 1 +
> fs/readdir.c | 49 +++++++++
> include/linux/fs.h | 3 +
> 11 files changed, 328 insertions(+), 15 deletions(-)
> create mode 100644 fs/gfs2/dir_readahead.c
>
> --
> 1.8.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Michael Kerrisk Linux man-pages maintainer;
http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface", http://blog.man7.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 1/2] fs: Add dirreadahead syscall and VFS hooks
[not found] ` <1406309851-10628-2-git-send-email-adas-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-29 8:21 ` Michael Kerrisk
[not found] ` <CAHO5Pa2fW6mZRTao3uEx2p_X9GvO1btrbb9Bg2ns94+p4biKAQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Kerrisk @ 2014-07-29 8:21 UTC (permalink / raw)
To: Abhi Das; +Cc: Linux Kernel, Linux-Fsdevel, cluster-devel, Linux API
[CC+=linux-api]
On Fri, Jul 25, 2014 at 7:37 PM, Abhi Das <adas-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> Also adds a void *opaque field to struct dir_context that can be
> used by filesystems to temporarily store any context as this
> struct gets passed around in the fs.
>
> Signed-off-by: Abhi Das <adas-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> arch/x86/syscalls/syscall_32.tbl | 1 +
> arch/x86/syscalls/syscall_64.tbl | 1 +
> fs/readdir.c | 49 ++++++++++++++++++++++++++++++++++++++++
> include/linux/fs.h | 3 +++
> 4 files changed, 54 insertions(+)
>
> diff --git a/arch/x86/syscalls/syscall_32.tbl b/arch/x86/syscalls/syscall_32.tbl
> index d6b8679..3e0ef85 100644
> --- a/arch/x86/syscalls/syscall_32.tbl
> +++ b/arch/x86/syscalls/syscall_32.tbl
> @@ -360,3 +360,4 @@
> 351 i386 sched_setattr sys_sched_setattr
> 352 i386 sched_getattr sys_sched_getattr
> 353 i386 renameat2 sys_renameat2
> +354 i386 dirreadahead sys_dirreadahead
> diff --git a/arch/x86/syscalls/syscall_64.tbl b/arch/x86/syscalls/syscall_64.tbl
> index ec255a1..2ec0991 100644
> --- a/arch/x86/syscalls/syscall_64.tbl
> +++ b/arch/x86/syscalls/syscall_64.tbl
> @@ -323,6 +323,7 @@
> 314 common sched_setattr sys_sched_setattr
> 315 common sched_getattr sys_sched_getattr
> 316 common renameat2 sys_renameat2
> +317 common dirreadahead sys_dirreadahead
>
> #
> # x32-specific system call numbers start at 512 to avoid cache impact
> diff --git a/fs/readdir.c b/fs/readdir.c
> index 33fd922..d216db7 100644
> --- a/fs/readdir.c
> +++ b/fs/readdir.c
> @@ -198,6 +198,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
> struct linux_dirent __user * lastdirent;
> struct getdents_callback buf = {
> .ctx.actor = filldir,
> + .ctx.opaque = NULL,
> .count = count,
> .current_dir = dirent
> };
> @@ -278,6 +279,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
> struct linux_dirent64 __user * lastdirent;
> struct getdents_callback64 buf = {
> .ctx.actor = filldir64,
> + .ctx.opaque = NULL,
> .count = count,
> .current_dir = dirent
> };
> @@ -304,3 +306,50 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
> fdput(f);
> return error;
> }
> +
> +SYSCALL_DEFINE3(dirreadahead, unsigned int, fd,
> + loff_t __user *, offset, unsigned int, count)
> +{
> + struct fd f;
> + struct inode *inode;
> + int error = -ENOTDIR;
> + loff_t off = 0;
> + struct dir_context ctx = {.actor = NULL, .opaque = NULL};
> +
> + if (!count)
> + return -EINVAL;
> +
> + f = fdget(fd);
> + if (!f.file)
> + return -EBADF;
> +
> + inode = f.file->f_path.dentry->d_inode;
> +
> + error = -ENOTSUPP;
> + if (!f.file->f_op || !f.file->f_op->dir_readahead)
> + goto out;
> +
> + error = security_file_permission(f.file, MAY_READ);
> + if (error)
> + goto out;
> +
> + error = -EFAULT;
> + if (__get_user(ctx.pos, offset))
> + goto out;
> +
> + error = mutex_lock_killable(&inode->i_mutex);
> + if (error)
> + goto out;
> +
> + error = -ENOENT;
> + if (!IS_DEADDIR(inode)) {
> + error = f.file->f_op->dir_readahead(f.file, &ctx, count);
> + if (__put_user(ctx.pos, offset))
> + error = -EFAULT;
> + file_accessed(f.file);
> + }
> + mutex_unlock(&inode->i_mutex);
> +out:
> + fdput(f);
> + return error;
> +}
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 338e6f7..fae4a6e 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1438,9 +1438,11 @@ int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags);
> * to have different dirent layouts depending on the binary type.
> */
> typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
> +
> struct dir_context {
> const filldir_t actor;
> loff_t pos;
> + void *opaque;
> };
>
> struct block_device_operations;
> @@ -1463,6 +1465,7 @@ struct file_operations {
> ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
> ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
> int (*iterate) (struct file *, struct dir_context *);
> + int (*dir_readahead) (struct file *, struct dir_context *, unsigned int);
> unsigned int (*poll) (struct file *, struct poll_table_struct *);
> long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
> long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
> --
> 1.8.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Michael Kerrisk Linux man-pages maintainer;
http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface", http://blog.man7.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 1/2] fs: Add dirreadahead syscall and VFS hooks
[not found] ` <CAHO5Pa2fW6mZRTao3uEx2p_X9GvO1btrbb9Bg2ns94+p4biKAQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-07-31 3:31 ` Dave Chinner
0 siblings, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2014-07-31 3:31 UTC (permalink / raw)
To: Michael Kerrisk
Cc: Abhi Das, Linux Kernel, Linux-Fsdevel, cluster-devel, Linux API
On Tue, Jul 29, 2014 at 10:21:50AM +0200, Michael Kerrisk wrote:
> [CC+=linux-api]
>
> On Fri, Jul 25, 2014 at 7:37 PM, Abhi Das <adas-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > Also adds a void *opaque field to struct dir_context that can be
> > used by filesystems to temporarily store any context as this
> > struct gets passed around in the fs.
So the prototype is:
int dir_readahead(int fd, off64_t offset, unsigned int count);
Why do we need a new syscall for this?
$ man 2 readahead
....
ssize_t readahead(int fd, off64_t offset, size_t count);
....
EINVAL fd does not refer to a file type to which readahead() can be applied.
Cheers,
Dave.
--
Dave Chinner
david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-31 3:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1406309851-10628-1-git-send-email-adas@redhat.com>
2014-07-29 8:19 ` [RFC PATCH 0/2] dirreadahead system call Michael Kerrisk
[not found] ` <1406309851-10628-2-git-send-email-adas@redhat.com>
[not found] ` <1406309851-10628-2-git-send-email-adas-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-07-29 8:21 ` [RFC PATCH 1/2] fs: Add dirreadahead syscall and VFS hooks Michael Kerrisk
[not found] ` <CAHO5Pa2fW6mZRTao3uEx2p_X9GvO1btrbb9Bg2ns94+p4biKAQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-07-31 3:31 ` Dave Chinner
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).