Linux RAID subsystem development
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Shaohua Li <shli@kernel.org>
Cc: "linux-raid@vger.kernel.org" <linux-raid@vger.kernel.org>,
	Shaohua Li <shli@fb.com>, "neilb@suse.com" <neilb@suse.com>,
	Kernel Team <Kernel-team@fb.com>,
	"dan.j.williams@intel.com" <dan.j.williams@intel.com>,
	"hch@infradead.org" <hch@infradead.org>,
	"jes.sorensen@gmail.com" <jes.sorensen@gmail.com>
Subject: Re: [PATCH] md/bitmap: preserve whole sb_page when initializing bitmap
Date: Tue, 8 Aug 2017 18:50:59 +0000	[thread overview]
Message-ID: <B38136B1-E937-40AE-906E-B7294F7556C6@fb.com> (raw)
In-Reply-To: <20170808152856.bhoikpeuw7pg6yy5@kernel.org>

>> On 8/8/17, 8:30 AM, "Shaohua Li" <shli@kernel.org> wrote:

    On Tue, Aug 01, 2017 at 11:11:37PM -0700, Song Liu wrote:
    > When bitmap_resize() is used to initialize the bitmap, it is
    > necessary to preserve the whole page of sb_page instead of just
    > the header (bitmap_super_t). This is because the sb_page may
    > contain bitmap read from the disks (initialized by mdadm).
    > 
    > Note that, this code path is only triggered with certain
    > combinations of parameters. One example is when raid456 array
    > is created with write journal
    
    Good catch, this issue probably only exists with journal, because we write
    superblock there.
     
    > Signed-off-by: Song Liu <songliubraving@fb.com>
    > ---
    >  drivers/md/bitmap.c | 3 +--
    >  1 file changed, 1 insertion(+), 2 deletions(-)
    > 
    > diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
    > index 40f3cd7..93dd809 100644
    > --- a/drivers/md/bitmap.c
    > +++ b/drivers/md/bitmap.c
    > @@ -2118,7 +2118,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
    >  	if (store.sb_page && bitmap->storage.sb_page)
    >  		memcpy(page_address(store.sb_page),
    >  		       page_address(bitmap->storage.sb_page),
    > -		       sizeof(bitmap_super_t));
    > +		       init ? PAGE_SIZE : sizeof(bitmap_super_t));
    
    I think this should be 'roundup(sizeof(bitmap_super_t),
    bdev_logical_block_size(rdev->bdev))', we not always read one page.
    
The sb_page is read from from one device, but updated in all devices. So when 
different devices have different block sizes, we may still write wrong bitmap
to the devices. How about we make read_sb_page() and write_sb_page() both access
full page instead?

Thanks,
Song
 


      reply	other threads:[~2017-08-08 18:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-02  6:11 [PATCH] md/bitmap: preserve whole sb_page when initializing bitmap Song Liu
2017-08-08 15:29 ` Shaohua Li
2017-08-08 18:50   ` Song Liu [this message]

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=B38136B1-E937-40AE-906E-B7294F7556C6@fb.com \
    --to=songliubraving@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=dan.j.williams@intel.com \
    --cc=hch@infradead.org \
    --cc=jes.sorensen@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=shli@fb.com \
    --cc=shli@kernel.org \
    /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