Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967008AbcJFJRe (ORCPT ); Thu, 6 Oct 2016 05:17:34 -0400 Received: from mout.web.de ([212.227.15.3]:63366 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965629AbcJFJRb (ORCPT ); Thu, 6 Oct 2016 05:17:31 -0400 Subject: [PATCH 19/54] md/raid1: Replace printk() calls by the usage of higher level interfaces To: linux-raid@vger.kernel.org, Christoph Hellwig , Guoqing Jiang , Jens Axboe , Mike Christie , Neil Brown , Shaohua Li , Tomasz Majchrzak References: <566ABCD9.1060404@users.sourceforge.net> <786843ef-4b6f-eb04-7326-2f6f5b408826@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <10a63a58-0bcc-125f-3693-cb719a1297a8@users.sourceforge.net> Date: Thu, 6 Oct 2016 11:16:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <786843ef-4b6f-eb04-7326-2f6f5b408826@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:zKWXsbX0/fxLRFV20HNBprUfiJRAGCtpY4qUnVDL473kiKp0DK/ LssZXiZPRIfUyTFUYzLhMoCAfRly85/5P3mnqu2bA0ih3L49aJE3PvykLZF4T1VrED/qgJ3 nb7Vw9UOVFMciyoMc1OpQSj+ob/aEU8jGoL7xMHU6AhUBuH/Dz68/sNKaTr6kmqg7A2x3RE 97mkrEfZP73ew78uxsXAw== X-UI-Out-Filterresults: notjunk:1;V01:K0:ql3mGSYm3MU=:l3UZtrD52QsCeEJAB21+qx dGhgnCG95cSPlyyEsYyJYM+lAa6DIrFWHLRxxS49EiDWxS5ojWnl0ktvwgAPuCC/bdZf8SHrv RRlPRCqNpo1kyh762eq0tW6orVTNOh22sXUJCU4LsGi4jIzdJEbAGSex1CZ/cZ60Zyj1pllKv Pn2iDtbNM4GJNpsbZmA5Ajp680FOoe8m+zJ7CBFIdeZr7G6LZtvXNgkYJLIJclK9TmLE6cU3F x3k5P9MJqyFXIcuEMR+LSx2mnCwX79pRK1POsirpiy4zIFGTpjGi1UstasLpNuHEXJUwJxt5M DFzXcjkRiRdrO+PXTG6AuPRPFxw7eYjA366S1zm7Y5Z5JFQFA0RGaYcgL4K3o+opPuV7iIJgz 4t2WUGZkHW30wcs+xlTd9IHHx+vR4qHutafjxi7n66pJVj6NXzAmGGRjJCRfVf304WD3/+5Ya HB8IkS0z98MBR9DRgntqLAdgZtGLgkFHbQd0PP0ticXFvTFoV1gfj1ES6gERkxLBdNgwumDqq Nldf4jSRPVMwTCqf0TMQRuLOKp2BJygj+iCnHVeGpoY45G5LV5d+8y0Pb4NPwVbQElB4c9Q7V bwClR/VgXOn6oQvExRZ6FWZ+zbIGow7FMJY5Rb/+97P1eJN58vAVtcyda7GHbhoW7uD44uGTD +BXdD2FPi3Q3tHdaYUS2UsGShjs0bvHOSvDWZ/aRZmTyg3M4ZOcthqO/TGT/iNKyU6D+uBHGX khalrYhmrqz8dceh+01rQVR3cL9OxYj0amIUk1ZiHEJsJP8coPo4Qx6c9youLkw+7vI2M4NN+ wU+vuH6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7242 Lines: 200 From: Markus Elfring Date: Tue, 4 Oct 2016 20:30:07 +0200 1. Add a definition for the macros "MY_LOG_PREFIX" and "pr_fmt" so that their information can be used for consistent message output. 2. Prefer usage of some higher level macros over calling "printk" directly in this software module. Signed-off-by: Markus Elfring --- drivers/md/raid1.c | 91 ++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 3a1194e..9754b7d 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -31,6 +31,8 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define MY_LOG_PREFIX KBUILD_MODNAME ": " +#define pr_fmt(fmt) MY_LOG_PREFIX fmt #include #include #include @@ -347,13 +349,11 @@ static void raid1_end_read_request(struct bio *bio) * oops, read error: */ char b[BDEVNAME_SIZE]; - printk_ratelimited( - KERN_ERR "md/raid1:%s: %s: " - "rescheduling sector %llu\n", - mdname(conf->mddev), - bdevname(rdev->bdev, - b), - (unsigned long long)r1_bio->sector); + + pr_err_ratelimited("%s: %s: rescheduling sector %llu\n", + mdname(conf->mddev), + bdevname(rdev->bdev, b), + (unsigned long long)r1_bio->sector); set_bit(R1BIO_ReadError, &r1_bio->state); reschedule_retry(r1_bio); /* don't drop the reference on read_disk yet */ @@ -1457,34 +1457,34 @@ static void raid1_error(struct mddev *mddev, struct md_rdev *rdev) set_bit(MD_RECOVERY_INTR, &mddev->recovery); set_mask_bits(&mddev->flags, 0, BIT(MD_CHANGE_DEVS) | BIT(MD_CHANGE_PENDING)); - printk(KERN_ALERT - "md/raid1:%s: Disk failure on %s, disabling device.\n" - "md/raid1:%s: Operation continuing on %d devices.\n", - mdname(mddev), bdevname(rdev->bdev, b), - mdname(mddev), conf->raid_disks - mddev->degraded); + pr_alert("%s: Disk failure on %s, disabling device.\n" + MY_LOG_PREFIX "%s: Operation continuing on %d devices.\n", + mdname(mddev), bdevname(rdev->bdev, b), + mdname(mddev), conf->raid_disks - mddev->degraded); } static void print_conf(struct r1conf *conf) { int i; - printk(KERN_DEBUG "RAID1 conf printout:\n"); + pr_debug("conf printout:\n"); if (!conf) { - printk(KERN_DEBUG "(!conf)\n"); + pr_debug("(!conf)\n"); return; } - printk(KERN_DEBUG " --- wd:%d rd:%d\n", conf->raid_disks - conf->mddev->degraded, - conf->raid_disks); + pr_debug("--- wd:%d rd:%d\n", + conf->raid_disks - conf->mddev->degraded, + conf->raid_disks); rcu_read_lock(); for (i = 0; i < conf->raid_disks; i++) { char b[BDEVNAME_SIZE]; struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev); if (rdev) - printk(KERN_DEBUG " disk %d, wo:%d, o:%d, dev:%s\n", - i, !test_bit(In_sync, &rdev->flags), - !test_bit(Faulty, &rdev->flags), - bdevname(rdev->bdev,b)); + pr_debug("disk %d, wo:%d, o:%d, dev:%s\n", + i, !test_bit(In_sync, &rdev->flags), + !test_bit(Faulty, &rdev->flags), + bdevname(rdev->bdev, b)); } rcu_read_unlock(); } @@ -1821,11 +1821,10 @@ static int fix_sync_read_error(struct r1bio *r1_bio) * work just disable and interrupt the recovery. * Don't fail devices as that won't really help. */ - printk(KERN_ALERT "md/raid1:%s: %s: unrecoverable I/O read error" - " for block %llu\n", - mdname(mddev), - bdevname(bio->bi_bdev, b), - (unsigned long long)r1_bio->sector); + pr_alert("%s: %s: unrecoverable I/O read error for block %llu\n", + mdname(mddev), + bdevname(bio->bi_bdev, b), + (unsigned long long)r1_bio->sector); for (d = 0; d < conf->raid_disks * 2; d++) { rdev = conf->mirrors[d].rdev; if (!rdev || test_bit(Faulty, &rdev->flags)) @@ -2118,13 +2117,13 @@ static void fix_read_error(struct r1conf *conf, int read_disk, if (r1_sync_page_io(rdev, sect, s, conf->tmppage, READ)) { atomic_add(s, &rdev->corrected_errors); - printk(KERN_INFO - "md/raid1:%s: read error corrected " - "(%d sectors at %llu on %s)\n", - mdname(mddev), s, - (unsigned long long)(sect + - rdev->data_offset), - bdevname(rdev->bdev, b)); + pr_info("%s: read error corrected " + "(%d sectors at %llu on %s)\n", + mdname(mddev), + s, + (unsigned long long)(sect + + rdev->data_offset), + bdevname(rdev->bdev, b)); } rdev_dec_pending(rdev, mddev); } else @@ -2307,9 +2306,8 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio) read_more: disk = read_balance(conf, r1_bio, &max_sectors); if (disk == -1) { - printk(KERN_ALERT "md/raid1:%s: %s: unrecoverable I/O" - " read error for block %llu\n", - mdname(mddev), b, (unsigned long long)r1_bio->sector); + pr_alert("%s: %s: unrecoverable I/O read error for block %llu\n", + mdname(mddev), b, (unsigned long long)r1_bio->sector); raid_end_bio_io(r1_bio); } else { const unsigned long do_sync @@ -2325,8 +2323,7 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio) max_sectors); r1_bio->bios[r1_bio->read_disk] = bio; rdev = conf->mirrors[disk].rdev; - printk_ratelimited(KERN_ERR - "md/raid1:%s: redirecting sector %llu" + pr_err_ratelimited("%s: redirecting sector %llu" " to other mirror: %s\n", mdname(mddev), (unsigned long long)r1_bio->sector, @@ -2910,12 +2907,12 @@ static int raid1_run(struct mddev *mddev) bool discard_supported = false; if (mddev->level != 1) { - printk(KERN_ERR "md/raid1:%s: raid level not set to mirroring (%d)\n", + pr_err("%s: raid level not set to mirroring (%d)\n", mdname(mddev), mddev->level); return -EIO; } if (mddev->reshape_position != MaxSector) { - printk(KERN_ERR "md/raid1:%s: reshape_position set but not supported\n", + pr_err("%s: reshape_position set but not supported\n", mdname(mddev)); return -EIO; } @@ -2955,12 +2952,11 @@ static int raid1_run(struct mddev *mddev) mddev->recovery_cp = MaxSector; if (mddev->recovery_cp != MaxSector) - printk(KERN_NOTICE "md/raid1:%s: not clean" - " -- starting background reconstruction\n", - mdname(mddev)); - printk(KERN_INFO - "md/raid1:%s: active with %d out of %d mirrors\n", - mdname(mddev), mddev->raid_disks - mddev->degraded, + pr_notice("%s: not clean -- starting background reconstruction\n", + mdname(mddev)); + pr_info("%s: active with %d out of %d mirrors\n", + mdname(mddev), + mddev->raid_disks - mddev->degraded, mddev->raid_disks); /* @@ -3112,9 +3108,8 @@ static int raid1_reshape(struct mddev *mddev) rdev->raid_disk = d2; sysfs_unlink_rdev(mddev, rdev); if (sysfs_link_rdev(mddev, rdev)) - printk(KERN_WARNING - "md/raid1:%s: cannot register rd%d\n", - mdname(mddev), rdev->raid_disk); + pr_warn("%s: cannot register rd%d\n", + mdname(mddev), rdev->raid_disk); } if (rdev) newmirrors[d2++].rdev = rdev; -- 2.10.1