mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Zhao Mengmeng <zhaomzhao@126.com>
Cc: Jan Kara <jack@suse.cz>,
	jack@suse.com, zhaomengmeng@kylinos.cn,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] udf: refactor udf_next_aext() to handle error
Date: Wed, 25 Sep 2024 09:05:30 +0200	[thread overview]
Message-ID: <20240925070530.cddj4cs4ia7qy6qm@quack3> (raw)
In-Reply-To: <6b22baa6-a75f-45ff-a0cb-33ae0ecf4720@126.com>

On Tue 24-09-24 20:08:56, Zhao Mengmeng wrote:
> On 2024/9/20 23:47, Jan Kara wrote:
> > On Wed 18-09-24 17:36:33, Zhao Mengmeng wrote:
> >> diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
> >> index 91b6e2698e7e..b7361222f988 100644
> >> --- a/fs/udf/truncate.c
> >> +++ b/fs/udf/truncate.c
> >> @@ -85,7 +85,7 @@ void udf_truncate_tail_extent(struct inode *inode)
> >>  		BUG();
> >>  
> >>  	/* Find the last extent in the file */
> >> -	while ((netype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) {
> >> +	while (!udf_next_aext(inode, &epos, &eloc, &elen, &netype, 1)) {
> >>  		etype = netype;
> >>  		lbcount += elen;
> >>  		if (lbcount > inode->i_size) {
> > 
> > This should be checking for error (after the loop) so that we don't
> > accidentally try to truncate extents early in case of error.
> > 
> Sorry to bother, in case of error(including EOF), it won't go into the loop and
> has chance to call extent_trunc(). After the loop, only some update and clean op,
> 
> 	iinfo->i_lenExtents = inode->i_size;
> 	brelse(epos.bh);
> 
> So I'm a little confused which part of this piece of code needs to change?

So if we are not able to scan until EOF due to error, we should set
i_lenExtents to i_size but you're right this is mostly a cosmetic thing.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2024-09-25  7:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-18  9:36 [PATCH 0/3] udf: refactor udf_current_aext()/udf_next_aext() " Zhao Mengmeng
2024-09-18  9:36 ` [PATCH 1/3] udf: refactor udf_current_aext() " Zhao Mengmeng
2024-09-20 15:09   ` Jan Kara
2024-09-23  1:35     ` Zhao Mengmeng
2024-09-18  9:36 ` [PATCH 2/3] udf: refactor udf_next_aext() " Zhao Mengmeng
2024-09-20 15:47   ` Jan Kara
2024-09-23  3:05     ` Zhao Mengmeng
2024-09-24 12:08     ` Zhao Mengmeng
2024-09-25  7:05       ` Jan Kara [this message]
2024-09-18  9:36 ` [PATCH 3/3] udf: refactor inode_bmap() " Zhao Mengmeng
2024-09-20 16:00   ` Jan Kara

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=20240925070530.cddj4cs4ia7qy6qm@quack3 \
    --to=jack@suse.cz \
    --cc=jack@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhaomengmeng@kylinos.cn \
    --cc=zhaomzhao@126.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

all inboxes | Powered by JetHome®