From patchwork Fri Oct 13 12:45:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 10004655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6319460360 for ; Fri, 13 Oct 2017 13:01:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55C822905B for ; Fri, 13 Oct 2017 13:01:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AB4529060; Fri, 13 Oct 2017 13:01:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E09F02905B for ; Fri, 13 Oct 2017 13:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758117AbdJMMrS (ORCPT ); Fri, 13 Oct 2017 08:47:18 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:49668 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758075AbdJMMrO (ORCPT ); Fri, 13 Oct 2017 08:47:14 -0400 Received: by mail-wm0-f68.google.com with SMTP id b189so21112670wmd.4 for ; Fri, 13 Oct 2017 05:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kKU5aRamDQK1bulJGwFM05EWYNQLEAuZlykvKQOk6Ss=; b=s6Vf83J+MzrZlx+iXkAe8QC26KwzEVhBL9cwZ4vS1ISp4iqdJFUQzAw762qZyqE0cM nH+umdU0PRKwO0NsGWthanBqhKbbNyyMRsovIw1g5jxxwUiSDTZEDz281Hag6bquUb4i L+9mEC9f3ZM3dgouNXn7xs+NxSJwgqQCeDiIc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kKU5aRamDQK1bulJGwFM05EWYNQLEAuZlykvKQOk6Ss=; b=WAbBL+k2Lnju8uAoMlS0bEW8iOl4IIlNINUeOu+S9JzW9KoOj3p9HQc+nI6YpxW9T1 eN8uYN58WKTBQFl2CL7/6xBtdpeiCf3Bqq5O2G7Xiifkln2yeZzFdousL8UpYvd9XCsL fSVCkGs1ClukLcncmtA5PsIIOnWK1kb4phfNMPd4NTUrJbfobq7WUkI2tUHGflQv1Mk3 HuRGFR2X9bo9B4QPqbLy1PVI0OwGnH5B2U4RdtVk/xNMx1or21kEeLvVmPaujrjud5+E hXPg7D1wIfrZlR0aFX0Xju6NPWhqLnUlkOWIv93tSwTFvIGw0I9kFqHKaxGFiibKhS+N GDdg== X-Gm-Message-State: AMCzsaXscahZKQPlmuxsFeero7CGWtMKDcr2RRhOZM43x1PkAOV9ruC7 ZcZSdoqUiKuj44JTe2PoYvynJA== X-Google-Smtp-Source: AOwi7QDROeGhBCAK3+ZV9XHs0DHyIsuPdRgcvrv4uUp6jNVfw3pMPcz1BCQDN2KK1jjU0240JA0wJw== X-Received: by 10.80.182.193 with SMTP id f1mr2051609ede.155.1507898833361; Fri, 13 Oct 2017 05:47:13 -0700 (PDT) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id p91sm735012edp.69.2017.10.13.05.47.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 05:47:12 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Rakesh Pandit , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 07/58] lightnvm: pblk: protect line bitmap while submitting meta io Date: Fri, 13 Oct 2017 14:45:56 +0200 Message-Id: <20171013124647.32668-8-m@bjorling.me> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171013124647.32668-1-m@bjorling.me> References: <20171013124647.32668-1-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rakesh Pandit It seems pblk_dealloc_page would race against pblk_alloc_pages for line bitmap for sector allocation.The chances are very low but might as well protect the bitmap properly. Signed-off-by: Rakesh Pandit Reviewed-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 8150164..b53bb00 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -486,12 +486,14 @@ void pblk_dealloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs) u64 addr; int i; + spin_lock(&line->lock); addr = find_next_zero_bit(line->map_bitmap, pblk->lm.sec_per_line, line->cur_sec); line->cur_sec = addr - nr_secs; for (i = 0; i < nr_secs; i++, line->cur_sec--) WARN_ON(!test_and_clear_bit(line->cur_sec, line->map_bitmap)); + spin_unlock(&line->lock); } u64 __pblk_alloc_page(struct pblk *pblk, struct pblk_line *line, int nr_secs)