[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250915111228.4142222-1-alexjlzheng@tencent.com>
Date: Mon, 15 Sep 2025 19:12:28 +0800
From: Jinliang Zheng <alexjlzheng@...il.com>
To: kernel@...kajraghav.com
Cc: alexjlzheng@...il.com,
alexjlzheng@...cent.com,
brauner@...nel.org,
djwong@...nel.org,
hch@...radead.org,
linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-xfs@...r.kernel.org,
yi.zhang@...wei.com
Subject: Re: [PATCH 4/4] iomap: don't abandon the whole copy when we have iomap_folio_state
On Mon, 15 Sep 2025 12:50:54 +0200, kernel@...kajraghav.com wrote:
> > +static int iomap_trim_tail_partial(struct inode *inode, loff_t pos,
> > + size_t copied, struct folio *folio)
> > +{
> > + struct iomap_folio_state *ifs = folio->private;
> > + unsigned block_size, last_blk, last_blk_bytes;
> > +
> > + if (!ifs || !copied)
> > + return 0;
> > +
> > + block_size = 1 << inode->i_blkbits;
> > + last_blk = offset_in_folio(folio, pos + copied - 1) >> inode->i_blkbits;
> > + last_blk_bytes = (pos + copied) & (block_size - 1);
> > +
> > + if (!ifs_block_is_uptodate(ifs, last_blk))
> > + copied -= min(copied, last_blk_bytes);
>
> If pos is aligned to block_size, is there a scenario where
> copied < last_blk_bytes?
I believe there is no other scenario. The min() here is specifically to handle cases where
pos is not aligned to block_size. But please note that the pos here is unrelated to the pos
in iomap_adjust_read_range().
thanks,
Jinliang Zheng. :)
>
> Trying to understand why you are using a min() here.
> --
> Pankaj
Powered by blists - more mailing lists