From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Damien Le Moal <damien.lemoal@opensource.wdc.com>,
Chaitanya Kulkarni <chaitanyak@nvidia.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "axboe@kernel.dk" <axboe@kernel.dk>,
"johannes.thumshirn@wdc.com" <johannes.thumshirn@wdc.com>,
"bvanassche@acm.org" <bvanassche@acm.org>,
"ming.lei@redhat.com" <ming.lei@redhat.com>,
"shinichiro.kawasaki@wdc.com" <shinichiro.kawasaki@wdc.com>,
"vincent.fu@samsung.com" <vincent.fu@samsung.com>,
"yukuai3@huawei.com" <yukuai3@huawei.com>
Subject: Re: [PATCH 3/6] null_blk: code cleaup
Date: Wed, 5 Oct 2022 05:21:20 +0000 [thread overview]
Message-ID: <6c0cafed-c600-d499-ac26-13e4fa00737b@nvidia.com> (raw)
In-Reply-To: <b96c6d74-3436-c4c4-4c25-23960a1b3cc8@opensource.wdc.com>
On 10/4/22 22:02, Damien Le Moal wrote:
> On 10/5/22 12:16, Chaitanya Kulkarni wrote:
>> Introduce and use two new macros for calculating the page index from
>> given sector and index (offset) of the sector in the page.
>> The newly added macros makes code easy to read with meaningful name and
>> explanation comments attached to it.
>>
>> While at it adjust the code in the null_free_sector() to return early
>> to get rid of the extra identation.
>>
>> Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
>> ---
>> drivers/block/null_blk/main.c | 37 ++++++++++++++++++++---------------
>> 1 file changed, 21 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
>> index 2d592b4eb815..b82c2ffeb086 100644
>> --- a/drivers/block/null_blk/main.c
>> +++ b/drivers/block/null_blk/main.c
>> @@ -14,6 +14,11 @@
>> #undef pr_fmt
>> #define pr_fmt(fmt) "null_blk: " fmt
>>
>> +/* Gives page index for which this sector belongs to. */
>
> That is clear from the macro name. Not convinced this comment is useful.
>
>> +#define PAGE_IDX_FROM_SECT(sect) (sect >> PAGE_SECTORS_SHIFT)
>> +/* Gives index (offset) of the sector within page. */
>> +#define SECT_IDX_IN_PAGE(sect) ((sect & SECTOR_MASK) << SECTOR_SHIFT)
>
> SECT_OFFSET_IN_PAGE() ? A "page" not being an array of sectors, using
> index for a sector is a little strange I think. And you use this macro for
> things like:
>
> offset = SECT_IDX_IN_PAGE(sect);
>
> So offset in the name makes more sense.
>
>
okay I'll make it to SECT_OFFSET_IN_PAGE()
-ck
next prev parent reply other threads:[~2022-10-05 5:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-05 3:16 [PATCH 0/6] null_blk: allow REQ_OP_WRITE_ZEROES and cleanup Chaitanya Kulkarni
2022-10-05 3:16 ` [PATCH 1/6] null_blk: allow write zeores on non-membacked Chaitanya Kulkarni
2022-10-05 4:54 ` Damien Le Moal
2022-10-05 5:24 ` Chaitanya Kulkarni
2022-10-05 18:33 ` Chaitanya Kulkarni
2022-10-05 3:16 ` [PATCH 2/6] null_blk: allow write zeores on membacked Chaitanya Kulkarni
2022-10-05 4:57 ` Damien Le Moal
2022-10-05 5:10 ` Chaitanya Kulkarni
2022-10-05 17:18 ` Brian Foster
2022-10-05 3:16 ` [PATCH 3/6] null_blk: code cleaup Chaitanya Kulkarni
2022-10-05 5:02 ` Damien Le Moal
2022-10-05 5:21 ` Chaitanya Kulkarni [this message]
2022-10-05 3:16 ` [PATCH 4/6] null_blk: initialize cmd->bio in __alloc_cmd() Chaitanya Kulkarni
2022-10-05 5:04 ` Damien Le Moal
2022-10-05 3:17 ` [PATCH 5/6] null_blk: don't use magic numbers in the code Chaitanya Kulkarni
2022-10-05 5:05 ` Damien Le Moal
2022-10-05 3:17 ` [PATCH 6/6] null_blk: remove extra space in switch condition Chaitanya Kulkarni
2022-10-05 5:06 ` Damien Le Moal
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=6c0cafed-c600-d499-ac26-13e4fa00737b@nvidia.com \
--to=chaitanyak@nvidia.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=damien.lemoal@opensource.wdc.com \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=shinichiro.kawasaki@wdc.com \
--cc=vincent.fu@samsung.com \
--cc=yukuai3@huawei.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®