linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: David Howells <dhowells@redhat.com>
Cc: hch@lst.de, linux-block@vger.kernel.org
Subject: Re: How best to get the size of a blockdev from a file?
Date: Tue, 18 Apr 2023 17:34:56 +0200	[thread overview]
Message-ID: <20230418153456.GA10282@lst.de> (raw)
In-Reply-To: <1609851.1681812012@warthog.procyon.org.uk>

On Tue, Apr 18, 2023 at 11:00:12AM +0100, David Howells wrote:
> Hi Christoph,
> 
> It seems that my use of i_size_read(file_inode(in)) in filemap_splice_read()
> to get the size of the file to be spliced from doesn't work in the case of
> blockdevs and it always returns 0.
>
> What would be the best way to get the blockdev size?  Look at
> file->f_mapping->i_size maybe?

Yes.  Everything using an inode in generic read/write helpers always
needs to use file->f_mapping->host to get at the inode.  Not just for
the size.

      parent reply	other threads:[~2023-04-18 15:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230418100108epcas5p2d0f2a7a274e78731373986b3d4fced9b@epcas5p2.samsung.com>
2023-04-18 10:00 ` How best to get the size of a blockdev from a file? David Howells
2023-04-18 12:28   ` Kanchan Joshi
2023-04-18 14:05     ` Jason Yan
2023-04-20 19:04       ` Al Viro
2023-04-21  1:38         ` Jason Yan
2023-04-18 15:34   ` Christoph Hellwig [this message]

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=20230418153456.GA10282@lst.de \
    --to=hch@lst.de \
    --cc=dhowells@redhat.com \
    --cc=linux-block@vger.kernel.org \
    /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).