From: Jan Kara <jack@suse.cz>
To: Dan Williams <dan.j.williams@intel.com>
Cc: axboe@fb.com, jack@suse.cz, linux-nvdimm@ml01.01.org,
david@fromorbit.com, linux-kernel@vger.kernel.org,
Al Viro <viro@zeniv.linux.org.uk>,
ross.zwisler@linux.intel.com, willy@linux.intel.com,
akpm@linux-foundation.org, hch@lst.de
Subject: Re: [PATCH 4/5] block: introduce file_bd_inode()
Date: Thu, 22 Oct 2015 11:45:02 +0200 [thread overview]
Message-ID: <20151022094502.GF14445@quack.suse.cz> (raw)
In-Reply-To: <20151022064205.12700.63495.stgit@dwillia2-desk3.amr.corp.intel.com>
On Thu 22-10-15 02:42:05, Dan Williams wrote:
> Similar to the file_inode() helper, provide a helper to lookup the inode for a
> raw block device itself.
So I somewhat dislike the name file_bd_inode() since for struct file
pointing to a regular file, the result would be equivalent to file_inode()
but the name suggests (at least to me) it should return block device inode.
I'd name it like bdev_file_inode() to make it clear this is local to
block device code...
Honza
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> fs/block_dev.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 0a793c7930eb..3255dcec96b4 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -147,11 +147,16 @@ blkdev_get_block(struct inode *inode, sector_t iblock,
> return 0;
> }
>
> +static struct inode *file_bd_inode(struct file *file)
> +{
> + return file->f_mapping->host;
> +}
> +
> static ssize_t
> blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
> {
> struct file *file = iocb->ki_filp;
> - struct inode *inode = file->f_mapping->host;
> + struct inode *inode = file_bd_inode(file);
>
> if (IS_DAX(inode))
> return dax_do_io(iocb, inode, iter, offset, blkdev_get_block,
> @@ -329,7 +334,7 @@ static int blkdev_write_end(struct file *file, struct address_space *mapping,
> */
> static loff_t block_llseek(struct file *file, loff_t offset, int whence)
> {
> - struct inode *bd_inode = file->f_mapping->host;
> + struct inode *bd_inode = file_bd_inode(file);
> loff_t retval;
>
> mutex_lock(&bd_inode->i_mutex);
> @@ -340,7 +345,7 @@ static loff_t block_llseek(struct file *file, loff_t offset, int whence)
>
> int blkdev_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
> {
> - struct inode *bd_inode = filp->f_mapping->host;
> + struct inode *bd_inode = file_bd_inode(filp);
> struct block_device *bdev = I_BDEV(bd_inode);
> int error;
>
> @@ -1579,14 +1584,14 @@ EXPORT_SYMBOL(blkdev_put);
>
> static int blkdev_close(struct inode * inode, struct file * filp)
> {
> - struct block_device *bdev = I_BDEV(filp->f_mapping->host);
> + struct block_device *bdev = I_BDEV(file_bd_inode(filp));
> blkdev_put(bdev, filp->f_mode);
> return 0;
> }
>
> static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
> {
> - struct block_device *bdev = I_BDEV(file->f_mapping->host);
> + struct block_device *bdev = I_BDEV(file_bd_inode(file));
> fmode_t mode = file->f_mode;
>
> /*
> @@ -1611,7 +1616,7 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg)
> ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
> {
> struct file *file = iocb->ki_filp;
> - struct inode *bd_inode = file->f_mapping->host;
> + struct inode *bd_inode = file_bd_inode(file);
> loff_t size = i_size_read(bd_inode);
> struct blk_plug plug;
> ssize_t ret;
> @@ -1643,7 +1648,7 @@ EXPORT_SYMBOL_GPL(blkdev_write_iter);
> ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
> {
> struct file *file = iocb->ki_filp;
> - struct inode *bd_inode = file->f_mapping->host;
> + struct inode *bd_inode = file_bd_inode(file);
> loff_t size = i_size_read(bd_inode);
> loff_t pos = iocb->ki_pos;
>
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2015-10-22 9:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-22 6:41 [PATCH 0/5] block, dax: updates for 4.4 Dan Williams
2015-10-22 6:41 ` [PATCH 1/5] pmem, dax: clean up clear_pmem() Dan Williams
2015-10-22 6:41 ` [PATCH 2/5] dax: increase granularity of dax_clear_blocks() operations Dan Williams
2015-10-22 9:26 ` Jan Kara
2015-10-22 6:41 ` [PATCH 3/5] block, dax: fix lifetime of in-kernel dax mappings with dax_map_atomic() Dan Williams
2015-10-22 6:42 ` [PATCH 4/5] block: introduce file_bd_inode() Dan Williams
2015-10-22 9:45 ` Jan Kara [this message]
2015-10-22 15:41 ` Dan Williams
2015-10-22 6:42 ` [PATCH 5/5] block: enable dax for raw block devices Dan Williams
2015-10-22 9:35 ` Jan Kara
2015-10-22 16:05 ` Williams, Dan J
2015-10-22 21:08 ` Jan Kara
2015-10-22 23:41 ` Williams, Dan J
2015-10-24 12:21 ` Jan Kara
2015-10-23 23:32 ` Dan Williams
2015-10-24 14:49 ` Jan Kara
2015-10-25 21:22 ` Dave Chinner
2015-10-26 2:48 ` Dan Williams
2015-10-26 6:23 ` Dave Chinner
2015-10-26 7:20 ` Jan Kara
2015-10-26 8:56 ` Dan Williams
2015-10-26 22:19 ` Dave Chinner
2015-10-27 22:55 ` Ross Zwisler
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=20151022094502.GF14445@quack.suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=axboe@fb.com \
--cc=dan.j.williams@intel.com \
--cc=david@fromorbit.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@ml01.01.org \
--cc=ross.zwisler@linux.intel.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@linux.intel.com \
/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;
as well as URLs for NNTP newsgroup(s).