From: Su Yue <l@damenly.su>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/4] btrfs: inode: remove variable shadowing in btrfs_invalidatepage()
Date: Thu, 17 Dec 2020 14:08:12 +0800 [thread overview]
Message-ID: <h7olhsmr.fsf@damenly.su> (raw)
In-Reply-To: <ee628954-63db-2328-9d47-b1f0ed3bd8a7@gmx.com>
On Thu 17 Dec 2020 at 13:42, Qu Wenruo <quwenruo.btrfs@gmx.com>
wrote:
> On 2020/12/17 下午1:38, Su Yue wrote:
>>
>> On Thu 17 Dec 2020 at 12:57, Qu Wenruo <wqu@suse.com> wrote:
>>
>>> In btrfs_invalidatepage() we re-declare @tree variable as
>>> btrfs_ordered_inode_tree.
>>>
>>> Remove such variable shadowing which can be very confusing.
>>>
>>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>>> ---
>>> fs/btrfs/inode.c | 9 +++------
>>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
>>> index dced71bccaac..b4d36d138008 100644
>>> --- a/fs/btrfs/inode.c
>>> +++ b/fs/btrfs/inode.c
>>> @@ -8169,6 +8169,7 @@ static void btrfs_invalidatepage(struct
>>> page
>>> *page, unsigned int offset,
>>> unsigned int length)
>>> {
>>> struct btrfs_inode *inode = BTRFS_I(page->mapping->host);
>>> + struct btrfs_ordered_inode_tree *ordered_tree =
>>> &inode->ordered_tree;
>>>
>> Any reason for the declaration here? I didn't find that
>> patch[3/4] use it.
>
> Didn't that ordered_tree get used lines below?
>
>>
>>> struct extent_io_tree *tree = &inode->io_tree;
>>> struct btrfs_ordered_extent *ordered;
>>> struct extent_state *cached_state = NULL;
>>> @@ -8218,15 +8219,11 @@ static void
>>> btrfs_invalidatepage(struct page
>>> *page, unsigned int offset,
>>> * for the finish_ordered_io
>>> */
>>> if (TestClearPagePrivate2(page)) {
>>> - struct btrfs_ordered_inode_tree *tree;
>>> -
>> Better to just rename the @tree to @ordered_tree.
>
> Isn't that exactly what I did?
What I mean is that keep the declaration in the block since no
further use of it.
>
> Thanks,
> Qu
>>
>>> - tree = &inode->ordered_tree;
>>> -
>>> - spin_lock_irq(&tree->lock);
>>> + spin_lock_irq(&ordered_tree->lock);
>>> set_bit(BTRFS_ORDERED_TRUNCATED,
>>> &ordered->flags);
>>> ordered->truncated_len =
>>> min(ordered->truncated_len,
>>> start - ordered->file_offset);
>>> - spin_unlock_irq(&tree->lock);
>>> + spin_unlock_irq(&ordered_tree->lock);
>>>
>>> ASSERT(end - start + 1 < U32_MAX);
>>> if (btrfs_dec_test_ordered_pending(inode,
>>> &ordered,
>>
next prev parent reply other threads:[~2020-12-17 6:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-17 4:57 [PATCH 0/4] btrfs: inode: btrfs_invalidatepage() related refactor and fix for subpage Qu Wenruo
2020-12-17 4:57 ` [PATCH 1/4] btrfs: inode: use min() to replace open-code in btrfs_invalidatepage() Qu Wenruo
2020-12-17 4:57 ` [PATCH 2/4] btrfs: inode: remove variable shadowing " Qu Wenruo
2020-12-17 5:38 ` Su Yue
2020-12-17 5:42 ` Qu Wenruo
2020-12-17 6:08 ` Su Yue [this message]
2020-12-17 5:55 ` Nikolay Borisov
2020-12-17 5:59 ` Nikolay Borisov
2020-12-17 6:13 ` Qu Wenruo
2020-12-17 12:29 ` David Sterba
2020-12-17 4:57 ` [PATCH 3/4] btrfs: inode: move the timing of TestClearPagePrivate() " Qu Wenruo
2020-12-17 4:57 ` [PATCH RFC 4/4] btrfs: inode: make btrfs_invalidatepage() to be subpage compatible Qu Wenruo
2020-12-17 11:20 ` Filipe Manana
2020-12-22 4:38 ` Qu Wenruo
2020-12-17 14:51 ` Josef Bacik
2020-12-18 0:42 ` Qu Wenruo
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=h7olhsmr.fsf@damenly.su \
--to=l@damenly.su \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.com \
--cc=wqu@suse.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