linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: jfs-discussion@lists.sourceforge.net,
	linux-fsdevel@vger.kernel.org,
	"Darrick J . Wong" <djwong@kernel.org>
Subject: Re: [RFC PATCH 7/9] jfs: Read quota through the page cache
Date: Fri, 27 May 2022 14:56:52 +0100	[thread overview]
Message-ID: <YpDYpHG0cZM9E5lD@casper.infradead.org> (raw)
In-Reply-To: <YpBlF2xbfL2yY98n@infradead.org>

On Thu, May 26, 2022 at 10:43:51PM -0700, Christoph Hellwig wrote:
> >  static ssize_t jfs_quota_read(struct super_block *sb, int type, char *data,
> > +			      size_t len, loff_t pos)
> >  {
> >  	struct inode *inode = sb_dqopt(sb)->files[type];
> > +	struct address_space *mapping = inode->i_mapping;
> >  	size_t toread;
> > +	pgoff_t index;
> >  	loff_t i_size = i_size_read(inode);
> >  
> > +	if (pos > i_size)
> >  		return 0;
> > +	if (pos + len > i_size)
> > +		len = i_size - pos;
> >  	toread = len;
> > +	index = pos / PAGE_SIZE;
> > +
> >  	while (toread > 0) {
> > +		struct folio *folio = read_mapping_folio(mapping, index, NULL);
> > +		size_t tocopy = PAGE_SIZE - offset_in_page(pos);
> > +		void *src;
> > +
> > +		if (IS_ERR(folio))
> > +			return PTR_ERR(folio);
> > +
> > +		src = kmap_local_folio(folio, offset_in_folio(folio, pos));
> > +		memcpy(data, src, tocopy);
> > +		kunmap_local(src);
> 
> It would be great to have a memcpy_from_folio like the existing
> memcpy_from_page for this.

Yes, I agree.  It could copy more than a single page like
zero_user_segments() does.

> > +		folio_put(folio);
> >  
> >  		toread -= tocopy;
> >  		data += tocopy;
> > +		pos += tocopy;
> > +		index++;
> >  	}
> >  	return len;
> 
> And this whole helper is generic now.  It might be worth to move it
> into fs/quota/dquot.c as generic_quota_read.

I was thinking it was filemap_read_kernel(inode, pos, dst, len)
but perhaps both of these things ...

  reply	other threads:[~2022-05-27 13:57 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26 19:29 [RFC PATCH 0/9] Convert JFS to use iomap Matthew Wilcox (Oracle)
2022-05-26 19:29 ` [RFC PATCH 1/9] IOMAP_DIO_NOSYNC Matthew Wilcox (Oracle)
2022-05-27  5:35   ` Christoph Hellwig
2022-05-27 13:20     ` Matthew Wilcox
2022-05-26 19:29 ` [RFC PATCH 2/9] jfs: Add jfs_iomap_begin() Matthew Wilcox (Oracle)
2022-05-27  5:41   ` Christoph Hellwig
2022-05-27 13:45     ` Matthew Wilcox
2022-05-27 14:58       ` [Jfs-discussion] " Dave Kleikamp
2022-05-26 19:29 ` [RFC PATCH 3/9] jfs: Convert direct_IO read support to use iomap Matthew Wilcox (Oracle)
2022-05-26 19:29 ` [RFC PATCH 4/9] jfs: Convert direct_IO write " Matthew Wilcox (Oracle)
2022-05-26 19:29 ` [RFC PATCH 5/9] jfs: Remove old direct_IO support Matthew Wilcox (Oracle)
2022-05-26 19:29 ` [RFC PATCH 6/9] jfs: Handle bmap with iomap Matthew Wilcox (Oracle)
2022-05-26 19:29 ` [RFC PATCH 7/9] jfs: Read quota through the page cache Matthew Wilcox (Oracle)
2022-05-27  5:43   ` Christoph Hellwig
2022-05-27 13:56     ` Matthew Wilcox [this message]
2022-06-03 14:40     ` generic_quota_read Matthew Wilcox
2022-06-06  7:37       ` generic_quota_read Jan Kara
2022-05-26 19:29 ` [RFC PATCH 8/9] jfs: Write quota through the page cache Matthew Wilcox (Oracle)
2022-05-27  5:46   ` Christoph Hellwig
2022-05-26 19:29 ` [RFC PATCH 9/9] jfs: Convert buffered IO paths to iomap Matthew Wilcox (Oracle)
2022-05-28  0:02 ` [RFC PATCH 0/9] Convert JFS to use iomap Dave Chinner
2022-05-28  2:15   ` Matthew Wilcox
2022-05-28  5:36     ` Dave Chinner
2022-05-28 18:59       ` Theodore Ts'o
2022-05-29 23:51         ` Dave Chinner
2022-05-31 13:51           ` [Jfs-discussion] " Dave Kleikamp
2022-05-31 15:31             ` Matthew Wilcox
2022-05-31 15:56               ` Dave Kleikamp

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=YpDYpHG0cZM9E5lD@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=linux-fsdevel@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).