From patchwork Sat Jul 19 11:40:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Satoru Takeuchi X-Patchwork-Id: 4589321 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A6EB5C0514 for ; Sat, 19 Jul 2014 11:45:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C50A420120 for ; Sat, 19 Jul 2014 11:45:39 +0000 (UTC) Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mail.kernel.org (Postfix) with ESMTP id C3B372011D for ; Sat, 19 Jul 2014 11:45:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6JBf1xb029006; Sat, 19 Jul 2014 07:41:02 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s6JBf1OB023458 for ; Sat, 19 Jul 2014 07:41:01 -0400 Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.21]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6JBf1OY006201; Sat, 19 Jul 2014 07:41:01 -0400 Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6JBex9i026002 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL); Sat, 19 Jul 2014 07:40:59 -0400 Received: by mail-pa0-f52.google.com with SMTP id bj1so6967109pad.11 for ; Sat, 19 Jul 2014 04:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:from:to:cc:subject:in-reply-to:references :user-agent:mime-version:content-type; bh=+rYUSC7z/7wHFRbJ7/p3x5i8h13UBn5u4HzZEPTtMvI=; b=wGX7RB7KY39l2rJ3FbFx/3rLolqDWu63M8ryGxwNg7V2ajz3gfZclz5UeX7rUNsJTH ncLiZ5whe05jk2Sa9Bx0l6u2T/URnhKpft6PEh9ZaVgsY84EaE/O/JIz98yh61RpdtpI YQvxqjQVTKTmkLfcxs2XJD+eyX3N+OGhQM2J8+CFcFIumfFi8vG1QmNcHF1ZiZuJvIhp 8wO5qibxnbT1T4Z3T2LWzxrvqPGWMXicIgZ9AC6EZwVeWg4cSauKkUAcL4svWxnih/bv c1hBK1nddb+6d6WIr2b3w8wjtthd5ebIRYnHFazRoBb2p7G8z7XYM8PitwTYB/YynYFq mlWw== X-Received: by 10.68.162.34 with SMTP id xx2mr1020236pbb.120.1405770059062; Sat, 19 Jul 2014 04:40:59 -0700 (PDT) Received: from www2455ue.sakura.ne.jp.gmail.com (satoru-takeuchi.org. [219.94.241.229]) by mx.google.com with ESMTPSA id bp4sm11173892pdb.24.2014.07.19.04.40.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jul 2014 04:40:58 -0700 (PDT) Date: Sat, 19 Jul 2014 20:40:52 +0900 Message-ID: <87bnsl37az.wl%satoru.takeuchi@gmail.com> From: Satoru Takeuchi To: ejt@redhat.com, Akira Hayakawa In-Reply-To: References: <87egxr0wul.wl%satoru.takeuchi@gmail.com> <20140718100130.5bc9f9cc4e9ce674ab014423@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/23.4 Mule/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-RedHat-Spam-Score: -3.1 (BAYES_00, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.21 X-loop: dm-devel@redhat.com Cc: device-mapper development Subject: [dm-devel] [PATCH] dm-writeboost: Remove unsure BUG() from init_rambuf_pool X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Joe and Akira, At Sat, 19 Jul 2014 11:13:13 +0900, Satoru Takeuchi wrote: > > Hi Akira, > > 2014-07-18 10:01 GMT+09:00 Akira Hayakawa : > > Hi, Satoru, > > > > I totally agree with removing the BUG() at (2). > > > > However, I don't agree with setting the upper limit of nr_rambuf_pool. > > You are saying that any memory allocation failure on initialization should be avoided > > but that sounds going too far. Removing that possibility from all kernel codes is impossible in practice. > > Carefully terminating the initialization on allocation failure is sufficient. Both Akira and me seem to have completely different policy about the upper limit of nr_rambuf_pool argument. However both of us agree with removing unsure BUG() in int init_rambuf_pool(). So I wrote a patch to do so as a first step. Please apply this patch. In addition, I'd like to know your opinion about whether setting the upper limit of nr_rambuf_pool argument is neccesary or not. ======= From: Satoru Takeuchi If users set a very large value to nr_rambuf_pool argument, kernel would hit BUG() in the error route of init_rambuf_pool(). drivers/md/dm-writeboost-metadata.c: =============================================================================== ... static int init_rambuf_pool(struct wb_device *wb) { int r = 0; size_t i; wb->rambuf_pool = kmalloc(sizeof(struct rambuffer) * wb->nr_rambuf_pool, GFP_KERNEL); if (!wb->rambuf_pool) # It is true here. return -ENOMEM; wb->rambuf_cachep = kmem_cache_create("dmwb_rambuf", 1 << (wb->segment_size_order + SECTOR_SHIFT), 1 << (wb->segment_size_order + SECTOR_SHIFT), SLAB_RED_ZONE, NULL); if (!wb->rambuf_cachep) { r = -ENOMEM; # Enter this route or .... goto bad_cachep; } for (i = 0; i < wb->nr_rambuf_pool; i++) { size_t j; struct rambuffer *rambuf = wb->rambuf_pool + i; rambuf->data = kmem_cache_alloc(wb->rambuf_cachep, GFP_KERNEL); if (!rambuf->data) { ... # ... enter this route. goto bad_alloc_data; } check_buffer_alignment(rambuf->data); } return r; bad_alloc_data: kmem_cache_destroy(wb->rambuf_cachep); bad_cachep: kfree(wb->rambuf_pool); BUG(); # Kernel panic happens here. return r; } ... =============================================================================== Probably this BUG() was introduced erroneously and is safe to remove. Signed-off-by: Satoru Takeuchi Cc: Joe Thornber Cc: Akira Hayakawa --- drivers/md/dm-writeboost-metadata.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/md/dm-writeboost-metadata.c b/drivers/md/dm-writeboost-metadata.c index b7b3eb7..ce6ea056 100644 --- a/drivers/md/dm-writeboost-metadata.c +++ b/drivers/md/dm-writeboost-metadata.c @@ -702,7 +702,6 @@ bad_alloc_data: kmem_cache_destroy(wb->rambuf_cachep); bad_cachep: kfree(wb->rambuf_pool); - BUG(); return r; }