All of lore.kernel.org
 help / color / mirror / Atom feed
From: kaixuxia <xiakaixu1987@gmail.com>
To: Eric Sandeen <sandeen@sandeen.net>, linux-xfs@vger.kernel.org
Cc: darrick.wong@oracle.com, Kaixu Xia <kaixuxia@tencent.com>
Subject: Re: [PATCH] xfs: use the SECTOR_SHIFT macro instead of the magic number
Date: Tue, 20 Oct 2020 10:54:07 +0800	[thread overview]
Message-ID: <162b310a-5d23-d380-8e55-7319f35773a9@gmail.com> (raw)
In-Reply-To: <771644f3-99dd-bdad-ef34-60f65faecd1a@sandeen.net>



On 2020/10/20 0:32, Eric Sandeen wrote:
> On 10/19/20 4:47 AM, xiakaixu1987@gmail.com wrote:
>> From: Kaixu Xia <kaixuxia@tencent.com>
>>
>> We use the SECTOR_SHIFT macro to define the sector size shift, so maybe
>> it is more reasonable to use it than the magic number 9.
>>
>> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
> 
> Hm ...  SECTOR_SHIFT is a block layer #define, really,
> and blkdev_issue_zeroout is a block layer interface I guess.
> 
> We also have our own BBSHIFT in XFS which is used elsewhere, though.
> 
> And FWIW, /many/ other fs/* manipulations still use the "- 9" today when
> converting s_blocksize_bits to sectors.  *shrug* this seems like something
> that should change tree-wide, if it's to be changed at all.
> 

Yeah, I think the magic number 9 is insecure, maybe a patchset is needed to
change them :)

Thanks,
Kaixu

> -Eric
> 
>> ---
>>  fs/xfs/xfs_bmap_util.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
>> index f2a8a0e75e1f..9f02c1824205 100644
>> --- a/fs/xfs/xfs_bmap_util.c
>> +++ b/fs/xfs/xfs_bmap_util.c
>> @@ -63,8 +63,8 @@ xfs_zero_extent(
>>  	sector_t		block = XFS_BB_TO_FSBT(mp, sector);
>>  
>>  	return blkdev_issue_zeroout(target->bt_bdev,
>> -		block << (mp->m_super->s_blocksize_bits - 9),
>> -		count_fsb << (mp->m_super->s_blocksize_bits - 9),
>> +		block << (mp->m_super->s_blocksize_bits - SECTOR_SHIFT),
>> +		count_fsb << (mp->m_super->s_blocksize_bits - SECTOR_SHIFT),
>>  		GFP_NOFS, 0);
>>  }
>>  
>>

-- 
kaixuxia

  reply	other threads:[~2020-10-20  2:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19  9:47 [PATCH] xfs: remove the unused BBMASK macro xiakaixu1987
2020-10-19  9:47 ` [PATCH] xfs: use the SECTOR_SHIFT macro instead of the magic number xiakaixu1987
2020-10-19 16:32   ` Eric Sandeen
2020-10-20  2:54     ` kaixuxia [this message]
2020-10-19 13:54 ` [PATCH] xfs: remove the unused BBMASK macro Eric Sandeen
2020-10-19 16:08   ` Darrick J. Wong
2020-10-27 18:46     ` Christoph Hellwig
2020-10-20  2:59   ` kaixuxia
2020-10-27 18:44 ` Christoph Hellwig

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=162b310a-5d23-d380-8e55-7319f35773a9@gmail.com \
    --to=xiakaixu1987@gmail.com \
    --cc=darrick.wong@oracle.com \
    --cc=kaixuxia@tencent.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.