summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2016-11-02 14:16:49 +1100
committerShaohua Li <shli@fb.com>2016-11-07 15:08:21 -0800
commit7f0f0d87fa172c71f74ea916d70765862ee2d53a (patch)
tree4c304ea8bfbea2907b8d135c7e5f7b846a0e3d75 /drivers
parentcbb387323610295be9d36c51287b668c1140704f (diff)
downloadlinux-7f0f0d87fa172c71f74ea916d70765862ee2d53a.tar.bz2
md: fix some issues with alloc_disk_sb()
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> Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/md.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 94f882af94aa..88c182190151 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;
}
@@ -8788,15 +8785,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;