From: NeilBrown <neilb@suse.com>
To: Shaohua Li <shli@kernel.org>
Cc: linux-raid@vger.kernel.org
Subject: [md PATCH 1/9] md: fix some issues with alloc_disk_sb()
Date: Wed, 02 Nov 2016 14:16:49 +1100 [thread overview]
Message-ID: <147805660892.23566.6467773696190310278.stgit@noble> (raw)
In-Reply-To: <147805657658.23566.1748253447749986766.stgit@noble>
1/ don't print a warning if allocation fails.
page_alloc() does that already.
2/ always check return status for error.
Signed-off-by: NeilBrown <neilb@suse.com>
---
drivers/md/md.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 18d0c4adbd7b..e3d20fb1d839 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -684,11 +684,8 @@ static inline sector_t calc_dev_sboffset(struct md_rdev *rdev)
static int alloc_disk_sb(struct md_rdev *rdev)
{
rdev->sb_page = alloc_page(GFP_KERNEL);
- if (!rdev->sb_page) {
- printk(KERN_ALERT "md: out of memory.\n");
+ if (!rdev->sb_page)
return -ENOMEM;
- }
-
return 0;
}
@@ -8785,15 +8782,18 @@ static int read_rdev(struct mddev *mddev, struct md_rdev *rdev)
* variable in case we err in the future
*/
rdev->sb_page = NULL;
- alloc_disk_sb(rdev);
- ClearPageUptodate(rdev->sb_page);
- rdev->sb_loaded = 0;
- err = super_types[mddev->major_version].load_super(rdev, NULL, mddev->minor_version);
-
+ err = alloc_disk_sb(rdev);
+ if (err == 0) {
+ ClearPageUptodate(rdev->sb_page);
+ rdev->sb_loaded = 0;
+ err = super_types[mddev->major_version].
+ load_super(rdev, NULL, mddev->minor_version);
+ }
if (err < 0) {
pr_warn("%s: %d Could not reload rdev(%d) err: %d. Restoring old values\n",
__func__, __LINE__, rdev->desc_nr, err);
- put_page(rdev->sb_page);
+ if (rdev->sb_page)
+ put_page(rdev->sb_page);
rdev->sb_page = swapout;
rdev->sb_loaded = 1;
return err;
next prev parent reply other threads:[~2016-11-02 3:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-02 3:16 [md PATCH 0/9] replace printk() with pr_*() NeilBrown
2016-11-02 3:16 ` NeilBrown [this message]
2016-11-02 3:16 ` [md PATCH 3/9] md/bitmap: change all printk() to pr_*() NeilBrown
2016-11-02 3:16 ` [md PATCH 2/9] md: change all printk() to pr_err() or pr_warn() etc NeilBrown
2016-11-02 3:16 ` [md PATCH 5/9] md/multipath: replace printk() with pr_*() NeilBrown
2016-11-02 3:16 ` [md PATCH 4/9] md/linear: " NeilBrown
2016-11-02 3:16 ` [md PATCH 9/9] md/raid5: change printk() to pr_*() NeilBrown
2016-11-02 3:16 ` [md PATCH 8/9] md/raid10: " NeilBrown
2016-11-02 3:16 ` [md PATCH 7/9] md/raid1: " NeilBrown
2016-11-02 3:16 ` [md PATCH 6/9] md/raid0: replace printk() with pr_*() NeilBrown
2016-11-02 12:36 ` [md PATCH 0/9] " Hannes Reinecke
2016-11-02 21:14 ` NeilBrown
2016-11-04 21:36 ` Shaohua Li
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=147805660892.23566.6467773696190310278.stgit@noble \
--to=neilb@suse.com \
--cc=linux-raid@vger.kernel.org \
--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