From: "zhangyi (F)" <yi.zhang@huawei.com>
To: mszeredi@redhat.com
Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
miaoxie@huawei.com
Subject: Re: [PATCH 4/9] vfs: intercept reads to overlay files
Date: Mon, 20 Feb 2017 15:47:03 +0800 [thread overview]
Message-ID: <f50a5892-eccf-0865-96ad-337114a6944e@huawei.com> (raw)
In-Reply-To: <D39694FF47DA2A43B120BF3DF6163E7A10CD2335@DGGEMA504-MBX.china.huawei.com>
On 2017/2/18 00:10, Miklos Szeredi wrote:
> diff --git a/fs/open.c b/fs/open.c
> index 9921f70bc5ca..4916ccff29f5 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -762,6 +762,8 @@ static int do_dentry_open(struct file *f,
> if ((f->f_mode & FMODE_WRITE) &&
> likely(f->f_op->write || f->f_op->write_iter))
> f->f_mode |= FMODE_CAN_WRITE;
> + if (unlikely(d_inode(f->f_path.dentry) != inode))
> + f->f_mode |= FMODE_OVERLAY;
Can we just add flag to the "readonly && not copied" file, not all overlayfs files?
Beacuse we just want to check the ro file before copied-up.
> f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
>
> diff --git a/fs/overlay_util.c b/fs/overlay_util.c new file mode 100644 index 000000000000..0daff19bad0b
> --- /dev/null
> +++ b/fs/overlay_util.c
> @@ -0,0 +1,39 @@
> +/*
> + * Copyright (C) 2017 Red Hat, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> +it
> + * under the terms of the GNU General Public License version 2 as
> +published by
> + * the Free Software Foundation.
> + */
> +#if IS_ENABLED(CONFIG_OVERLAY_FS)
> +
> +#include <linux/overlay_util.h>
> +#include <linux/fs.h>
> +#include <linux/file.h>
> +#include "internal.h"
> +
> +static bool overlay_file_consistent(struct file *file) {
> + return d_real_inode(file->f_path.dentry) == file_inode(file); }
> +
> +ssize_t overlay_read_iter(struct file *file, struct kiocb *kio,
> + struct iov_iter *iter)
> +{
> + ssize_t ret;
> +
> + if (likely(overlay_file_consistent(file)))
> + return file->f_op->read_iter(kio, iter);
> +
> + file = filp_clone_open(file);
> + if (IS_ERR(file))
> + return PTR_ERR(file);
> +
> + ret = vfs_iter_read(file, iter, &kio->ki_pos);
> + fput(file);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(overlay_read_iter);
Can we try to replace the old file with the new file, and then clear the f_mode flag we added?
If so, we can avoid opening file for each reading call and avoid copied file consistency check.
Thanks.
zhangyi
next prev parent reply other threads:[~2017-02-20 7:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-17 16:09 [PATCH 0/9] overlay: fix inconsistency of ro file after copy-up Miklos Szeredi
2017-02-17 16:09 ` [PATCH 1/9] vfs: extract common parts of {compat_,}do_readv_writev() Miklos Szeredi
2017-02-17 16:09 ` [PATCH 2/9] vfs: pass type instead of fn to do_{loop,iter}_readv_writev() Miklos Szeredi
2017-02-17 16:09 ` [PATCH 3/9] vfs: use helpers for calling f_op->{read,write}_iter() Miklos Szeredi
2017-02-17 16:09 ` [PATCH 4/9] vfs: intercept reads to overlay files Miklos Szeredi
2017-02-19 9:05 ` Al Viro
2017-02-19 9:24 ` Miklos Szeredi
[not found] ` <D39694FF47DA2A43B120BF3DF6163E7A10CD2335@DGGEMA504-MBX.china.huawei.com>
2017-02-20 7:47 ` zhangyi (F) [this message]
2017-02-20 8:52 ` Miklos Szeredi
2017-02-17 16:09 ` [PATCH 5/9] mm: ovl: copy-up on MAP_SHARED Miklos Szeredi
2017-02-17 16:09 ` [PATCH 6/9] mm: use helper for calling f_op->mmap() Miklos Szeredi
2017-02-17 16:09 ` [PATCH 7/9] ovl: intercept mmap on overlay files Miklos Szeredi
2017-02-17 16:09 ` [PATCH 8/9] vfs: use helper for calling f_op->fsync() Miklos Szeredi
2017-02-17 16:09 ` [PATCH 9/9] vfs: intercept fsync on overlay files Miklos Szeredi
2017-02-19 9:14 ` [PATCH 0/9] overlay: fix inconsistency of ro file after copy-up Al Viro
2017-02-20 15:16 ` Miklos Szeredi
2017-03-07 16:26 ` Miklos Szeredi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f50a5892-eccf-0865-96ad-337114a6944e@huawei.com \
--to=yi.zhang@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miaoxie@huawei.com \
--cc=mszeredi@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox