From patchwork Thu Aug 2 04:18:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 952561 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41gxkB2zW1z9s2g; Thu, 2 Aug 2018 14:18:26 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fl548-0007AL-R8; Thu, 02 Aug 2018 04:18:20 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fl547-00079v-C8 for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:19 +0000 Received: from mail-pf1-f199.google.com ([209.85.210.199]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fl547-0001tv-0M for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:19 +0000 Received: by mail-pf1-f199.google.com with SMTP id v9-v6so659329pfn.6 for ; Wed, 01 Aug 2018 21:18:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=wZxteVjxHk4KevJ9hm1yuij9jZ1ZrHfSwLen828SWoU=; b=FWaAJD85+9mZ3iUWh+6uH+jjEQdiBGvKojoXwRgfGGSw5fMVmNMiX+UWlOL5Q3Kekv PI1rSkz0lmlhXDNaPN5NOzA+HRBYG0nkzGmz2Mtb9NSA2Pqn4ZUlKvSIZEHrYvybFW/6 vSZuog/r2Bh7gvgetF0SanOVIF2TSM1qfi4ClYZS87+PQ51XwgMS7eKBh/8P7tYdJJXP qud15C15dmijBmeUGUHa9+/qfoJ80JQBrVdbxPWgulOcsd4hhij18s4IQXNApeDYZS41 bwElyB5fmiulFR40Zo77IZoACelKc3s2bXY2ewagz09aDEpfxhIiwzimd8MxUYYM4LgF 8qiw== X-Gm-Message-State: AOUpUlEtEuFqBKoYy5welnohXMSFAsyiVBro3Rr43W69t1Ix/TIkNTl8 l1RjWB8OIWlINdpjQLqSmZTaqU2AkQhvvxQsCiUEhZu2ldSET57pbDft3AHvCkN8CZxTpKSJ5dW D76GVhe/tfLL1teMCCcpxqpY2kc/xUQaPZnxhfAHLuU2jpfji X-Received: by 2002:a65:6551:: with SMTP id a17-v6mr1112260pgw.132.1533183497719; Wed, 01 Aug 2018 21:18:17 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdRTy2UhQVlP36bO4zTo32J08NkKtiWdUgRgM9ywXda1ricAZ3HahCpXzL9LpclWestzWIenA== X-Received: by 2002:a65:6551:: with SMTP id a17-v6mr1112255pgw.132.1533183497601; Wed, 01 Aug 2018 21:18:17 -0700 (PDT) Received: from localhost.localdomain (124-171-193-200.dyn.iinet.net.au. [124.171.193.200]) by smtp.gmail.com with ESMTPSA id t186-v6sm639186pgd.77.2018.08.01.21.18.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 21:18:16 -0700 (PDT) From: Daniel Axtens To: kernel-team@lists.canonical.com Subject: [SRU X][PATCH 1/6] Revert "UBUNTU: SAUCE: CacheFiles: fix a read_waiter/read_copier race" Date: Thu, 2 Aug 2018 14:18:05 +1000 Message-Id: <20180802041810.22748-2-daniel.axtens@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802041810.22748-1-daniel.axtens@canonical.com> References: <20180802041810.22748-1-daniel.axtens@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1774336 Revert 9bd2e21fbe3786e23ce8a23d3e51f1e04f1f7800 in Xenial. Upstream has taken a different solution, which we're about to apply. Signed-off-by: Daniel Axtens --- fs/cachefiles/rdwr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c index d9bb47d1e16d..c0f3da3926a0 100644 --- a/fs/cachefiles/rdwr.c +++ b/fs/cachefiles/rdwr.c @@ -58,9 +58,9 @@ static int cachefiles_read_waiter(wait_queue_t *wait, unsigned mode, spin_lock(&object->work_lock); list_add_tail(&monitor->op_link, &monitor->op->to_do); - fscache_enqueue_retrieval(monitor->op); spin_unlock(&object->work_lock); + fscache_enqueue_retrieval(monitor->op); return 0; } From patchwork Thu Aug 2 04:18:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 952562 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41gxkD6WKdz9s3x; Thu, 2 Aug 2018 14:18:28 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fl54B-0007Bk-1I; Thu, 02 Aug 2018 04:18:23 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fl549-0007Af-8m for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:21 +0000 Received: from mail-pf1-f200.google.com ([209.85.210.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fl548-0001uH-Sx for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:21 +0000 Received: by mail-pf1-f200.google.com with SMTP id i68-v6so656227pfb.9 for ; Wed, 01 Aug 2018 21:18:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=GYLMuzmmVwmDwjpDFtVBI6RZD3T1PksqDo6aDHTCN2w=; b=JfGVPL/ugY38ZrgrKsh0Vq6qYI9uQHl6nhKzeRrkff7nltJrAvxosoGESpBgjX+GJx q6hdcRS+Uoemft2KisooLDGlNG8RRdbXZJtbnkkOk8prugGcF27S9EhAnprmLLkGEngl qndBjsGnKrk7aN8UNvo9gu7iI1JDI1LjkHwWDHmRO6GI5N9hTymBUS5Qsjipbox4YVDe +cUuoTggM30t/820Yr4FDA/U2RLCWb/eWywTpi2b/7twQXcw+d0ubBJuEO/0b8Q85YUv J/Cea71pjyDAK2p5CDlRlp7oqPPZBTi1HBZ8Jigq5oGaBJgEXWovPG+WeOweaBq0lB04 CG3Q== X-Gm-Message-State: AOUpUlGrjk2qzS8/ljuzT2erVG2YB3albsg2+d2/bUpdPcZEtHbYp4OL qF/sQRY1NC+2ycCpqgOuQI2mH1EtR7g11jxMhK0O4bMn/08Y15SBvO/sIYJxT5T742pAuRiczed Qc3qDF2EKpMu3OZohUNRy20vAs0BIQOmdWwEyBd4gYUYUrZ8c X-Received: by 2002:a63:951e:: with SMTP id p30-v6mr1113319pgd.318.1533183499593; Wed, 01 Aug 2018 21:18:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeHaX6CoKlWq4DdeW+977b8BTOLrKdhdmNH0Kheqo48JWbz1jF3d6fCSB/OZpeHz1zdkDEoZA== X-Received: by 2002:a63:951e:: with SMTP id p30-v6mr1113312pgd.318.1533183499456; Wed, 01 Aug 2018 21:18:19 -0700 (PDT) Received: from localhost.localdomain (124-171-193-200.dyn.iinet.net.au. [124.171.193.200]) by smtp.gmail.com with ESMTPSA id t186-v6sm639186pgd.77.2018.08.01.21.18.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 21:18:18 -0700 (PDT) From: Daniel Axtens To: kernel-team@lists.canonical.com Subject: [SRU X][PATCH 2/6] fscache: Allow cancelled operations to be enqueued Date: Thu, 2 Aug 2018 14:18:06 +1000 Message-Id: <20180802041810.22748-3-daniel.axtens@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802041810.22748-1-daniel.axtens@canonical.com> References: <20180802041810.22748-1-daniel.axtens@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kiran Kumar Modukuri BugLink: https://bugs.launchpad.net/bugs/1774336 Alter the state-check assertion in fscache_enqueue_operation() to allow cancelled operations to be given processing time so they can be cleaned up. Also fix a debugging statement that was requiring such operations to have an object assigned. Fixes: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem") Reported-by: Kiran Kumar Modukuri Signed-off-by: David Howells (cherry picked from commit d0eb06afe712b7b103b6361f40a9a0c638524669) Signed-off-by: Daniel Axtens --- fs/fscache/operation.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c index de67745e1cd7..77946d6f617d 100644 --- a/fs/fscache/operation.c +++ b/fs/fscache/operation.c @@ -66,7 +66,8 @@ void fscache_enqueue_operation(struct fscache_operation *op) ASSERT(op->processor != NULL); ASSERT(fscache_object_is_available(op->object)); ASSERTCMP(atomic_read(&op->usage), >, 0); - ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS); + ASSERTIFCMP(op->state != FSCACHE_OP_ST_IN_PROGRESS, + op->state, ==, FSCACHE_OP_ST_CANCELLED); fscache_stat(&fscache_n_op_enqueue); switch (op->flags & FSCACHE_OP_TYPE) { @@ -481,7 +482,8 @@ void fscache_put_operation(struct fscache_operation *op) struct fscache_cache *cache; _enter("{OBJ%x OP%x,%d}", - op->object->debug_id, op->debug_id, atomic_read(&op->usage)); + op->object ? op->object->debug_id : 0, + op->debug_id, atomic_read(&op->usage)); ASSERTCMP(atomic_read(&op->usage), >, 0); From patchwork Thu Aug 2 04:18:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 952563 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41gxkH1jkhz9rxx; Thu, 2 Aug 2018 14:18:31 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fl54D-0007D6-6n; Thu, 02 Aug 2018 04:18:25 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fl54B-0007CF-KO for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:23 +0000 Received: from mail-pf1-f199.google.com ([209.85.210.199]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fl54B-0001uc-8L for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:23 +0000 Received: by mail-pf1-f199.google.com with SMTP id l15-v6so669700pff.1 for ; Wed, 01 Aug 2018 21:18:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=lFdNL7dElWANZpCmuwMQR+e2ApfBijZ1QY4IpYnFlbA=; b=AoKhRKbCro8qyFK2GaGDtuLv5++ExOVCiI+pEr9sw0oCvCQl21ketnGLzRtYSnitNT gYZ+02Y/PKDNsPcNrvy0WIixP7fLcM9CmvGiD0mjFbK/zvjkou/0fdhhnYdx8sEfAQIy 4A54DzwkrT10isKplv5UXcQXmRnFOUQr5wD0ztLW2hUdslPybCAd08RgAGRJ6I9WWL9r K1UR2ae9fH6AjoVVX6qEHgTNp+xOlHNrEh2FpXkXCtywkb/OEk5CfTa7qBmdPjXwdrPp aevj/EHvHotxrgQZPemJIdBVNP5kbAODskXnvFBtZHhGaWaj/NzEPkLH7COLNaadJ0/U 5CIQ== X-Gm-Message-State: AOUpUlFa6x6yG6StlkpH2cA59UtTAx0a/exYplwqnwk1JUHRuJrJDlAS oYKgrI/a7Xievak/BIvv1uuHfRoN+rbAdDx2aRr84UXAVLfs4PIvpm4sQG9NbWgObsZRpWUZlUw kuSvf70S/zjTBKcIkK0M+T6zV6PzY4DTtboNaeYZN1FBAj0DL X-Received: by 2002:a63:27c1:: with SMTP id n184-v6mr1066249pgn.29.1533183501923; Wed, 01 Aug 2018 21:18:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdaGqfXC56GhpcTAs+sM5HcJQlSzLf2TMmmL9hl/bLWw3XYcKlFY/zno8GaeD9xl4TaqWlsLA== X-Received: by 2002:a63:27c1:: with SMTP id n184-v6mr1066245pgn.29.1533183501743; Wed, 01 Aug 2018 21:18:21 -0700 (PDT) Received: from localhost.localdomain (124-171-193-200.dyn.iinet.net.au. [124.171.193.200]) by smtp.gmail.com with ESMTPSA id t186-v6sm639186pgd.77.2018.08.01.21.18.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 21:18:20 -0700 (PDT) From: Daniel Axtens To: kernel-team@lists.canonical.com Subject: [SRU X][PATCH 3/6] cachefiles: Fix refcounting bug in backing-file read monitoring Date: Thu, 2 Aug 2018 14:18:07 +1000 Message-Id: <20180802041810.22748-4-daniel.axtens@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802041810.22748-1-daniel.axtens@canonical.com> References: <20180802041810.22748-1-daniel.axtens@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kiran Kumar Modukuri BugLink: https://bugs.launchpad.net/bugs/1774336 cachefiles_read_waiter() has the right to access a 'monitor' object by virtue of being called under the waitqueue lock for one of the pages in its purview. However, it has no ref on that monitor object or on the associated operation. What it is allowed to do is to move the monitor object to the operation's to_do list, but once it drops the work_lock, it's actually no longer permitted to access that object. However, it is trying to enqueue the retrieval operation for processing - but it can only do this via a pointer in the monitor object, something it shouldn't be doing. If it doesn't enqueue the operation, the operation may not get processed. If the order is flipped so that the enqueue is first, then it's possible for the work processor to look at the to_do list before the monitor is enqueued upon it. Fix this by getting a ref on the operation so that we can trust that it will still be there once we've added the monitor to the to_do list and dropped the work_lock. The op can then be enqueued after the lock is dropped. The bug can manifest in one of a couple of ways. The first manifestation looks like: FS-Cache: FS-Cache: Assertion failed FS-Cache: 6 == 5 is false ------------[ cut here ]------------ kernel BUG at fs/fscache/operation.c:494! RIP: 0010:fscache_put_operation+0x1e3/0x1f0 ... fscache_op_work_func+0x26/0x50 process_one_work+0x131/0x290 worker_thread+0x45/0x360 kthread+0xf8/0x130 ? create_worker+0x190/0x190 ? kthread_cancel_work_sync+0x10/0x10 ret_from_fork+0x1f/0x30 This is due to the operation being in the DEAD state (6) rather than INITIALISED, COMPLETE or CANCELLED (5) because it's already passed through fscache_put_operation(). The bug can also manifest like the following: kernel BUG at fs/fscache/operation.c:69! ... [exception RIP: fscache_enqueue_operation+246] ... #7 [ffff883fff083c10] fscache_enqueue_operation at ffffffffa0b793c6 #8 [ffff883fff083c28] cachefiles_read_waiter at ffffffffa0b15a48 #9 [ffff883fff083c48] __wake_up_common at ffffffff810af028 I'm not entirely certain as to which is line 69 in Lei's kernel, so I'm not entirely clear which assertion failed. Fixes: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem") Reported-by: Lei Xue Reported-by: Vegard Nossum Reported-by: Anthony DeRobertis Reported-by: NeilBrown Reported-by: Daniel Axtens Reported-by: Kiran Kumar Modukuri Signed-off-by: David Howells Reviewed-by: Daniel Axtens (cherry picked from commit 934140ab028713a61de8bca58c05332416d037d1) Signed-off-by: Daniel Axtens --- fs/cachefiles/rdwr.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c index c0f3da3926a0..5b68cf526887 100644 --- a/fs/cachefiles/rdwr.c +++ b/fs/cachefiles/rdwr.c @@ -27,6 +27,7 @@ static int cachefiles_read_waiter(wait_queue_t *wait, unsigned mode, struct cachefiles_one_read *monitor = container_of(wait, struct cachefiles_one_read, monitor); struct cachefiles_object *object; + struct fscache_retrieval *op = monitor->op; struct wait_bit_key *key = _key; struct page *page = wait->private; @@ -51,16 +52,22 @@ static int cachefiles_read_waiter(wait_queue_t *wait, unsigned mode, list_del(&wait->task_list); /* move onto the action list and queue for FS-Cache thread pool */ - ASSERT(monitor->op); + ASSERT(op); - object = container_of(monitor->op->op.object, - struct cachefiles_object, fscache); + /* We need to temporarily bump the usage count as we don't own a ref + * here otherwise cachefiles_read_copier() may free the op between the + * monitor being enqueued on the op->to_do list and the op getting + * enqueued on the work queue. + */ + fscache_get_retrieval(op); + object = container_of(op->op.object, struct cachefiles_object, fscache); spin_lock(&object->work_lock); - list_add_tail(&monitor->op_link, &monitor->op->to_do); + list_add_tail(&monitor->op_link, &op->to_do); spin_unlock(&object->work_lock); - fscache_enqueue_retrieval(monitor->op); + fscache_enqueue_retrieval(op); + fscache_put_retrieval(op); return 0; } From patchwork Thu Aug 2 04:18:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 952564 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41gxkK1fxNz9rxx; Thu, 2 Aug 2018 14:18:33 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fl54F-0007Eg-DW; Thu, 02 Aug 2018 04:18:27 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fl54D-0007De-OY for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:25 +0000 Received: from mail-pg1-f200.google.com ([209.85.215.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fl54D-0001us-8Q for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:25 +0000 Received: by mail-pg1-f200.google.com with SMTP id w23-v6so492493pgv.1 for ; Wed, 01 Aug 2018 21:18:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=yCB7eSbH9dSvsqL0ScDU4EduX/gDorI/f+pjgu8IBgU=; b=Xj+j2Y/OfDfAc5/J4aB6cEpLrVeWHDhQGbMG6M4Gj+vrdgso6sQnWHdsT1ZYs99aAk n19J/1fKiaQItyMnjTlkZv0FaDNz7eB4c/7q14uS2j/+SZx0DV91dkxfwqGG1ohryyDF WNOxyXZGv7yEoKTWHCsIpHVacuYP1ZHvqjVzakvqKuiAHpt8Ku0vIl1HEv1PtmjSbw7n jHNHd1wN6KBpt2EvpBH4pG7X5PiD2MV9zBVFG4QJ7+ZDEvaeQ7DVzjgiq4kZHnu84ZNH 2PDfAWFTK9590br5dyh2tMzCVxS1EN9Yf5MoZs1Mmel/zgeWo9n3JpbCPwjDuoR4By9v rHqw== X-Gm-Message-State: AOUpUlFln90VYTcDSPiP0QFOOrxWZ1eY+VrVS4zneJACjsoV1zxKWBL3 aJExmSjBYBFpkvgQX2ShW3sT8E1z0oVQePwFjyMlRQgTEl7dNJFna8JllioUg6eBYKE4DKBqmor h8LZEngvx/FzJDfpwjBUn5ibPBy2eWVCIZQPnxP3/3pAXoPrr X-Received: by 2002:a62:6a01:: with SMTP id f1-v6mr1227137pfc.156.1533183503888; Wed, 01 Aug 2018 21:18:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf0Q2WefBXzM19qSdtr8DNi4x1pMf0oOVde1qMNYHLWDz82mkK954pSKXYZNY9m9ht0LouCsQ== X-Received: by 2002:a62:6a01:: with SMTP id f1-v6mr1227126pfc.156.1533183503679; Wed, 01 Aug 2018 21:18:23 -0700 (PDT) Received: from localhost.localdomain (124-171-193-200.dyn.iinet.net.au. [124.171.193.200]) by smtp.gmail.com with ESMTPSA id t186-v6sm639186pgd.77.2018.08.01.21.18.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 21:18:23 -0700 (PDT) From: Daniel Axtens To: kernel-team@lists.canonical.com Subject: [SRU X][PATCH 4/6] fscache: Fix reference overput in fscache_attach_object() error handling Date: Thu, 2 Aug 2018 14:18:08 +1000 Message-Id: <20180802041810.22748-5-daniel.axtens@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802041810.22748-1-daniel.axtens@canonical.com> References: <20180802041810.22748-1-daniel.axtens@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kiran Kumar Modukuri BugLink: https://bugs.launchpad.net/bugs/1776277 When a cookie is allocated that causes fscache_object structs to be allocated, those objects are initialised with the cookie pointer, but aren't blessed with a ref on that cookie unless the attachment is successfully completed in fscache_attach_object(). If attachment fails because the parent object was dying or there was a collision, fscache_attach_object() returns without incrementing the cookie counter - but upon failure of this function, the object is released which then puts the cookie, whether or not a ref was taken on the cookie. Fix this by taking a ref on the cookie when it is assigned in fscache_object_init(), even when we're creating a root object. Analysis from Kiran Kumar: This bug has been seen in 4.4.0-124-generic #148-Ubuntu kernel BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1776277 fscache cookie ref count updated incorrectly during fscache object allocation resulting in following Oops. kernel BUG at /build/linux-Y09MKI/linux-4.4.0/fs/fscache/internal.h:321! kernel BUG at /build/linux-Y09MKI/linux-4.4.0/fs/fscache/cookie.c:639! [Cause] Two threads are trying to do operate on a cookie and two objects. (1) One thread tries to unmount the filesystem and in process goes over a huge list of objects marking them dead and deleting the objects. cookie->usage is also decremented in following path: nfs_fscache_release_super_cookie -> __fscache_relinquish_cookie ->__fscache_cookie_put ->BUG_ON(atomic_read(&cookie->usage) <= 0); (2) A second thread tries to lookup an object for reading data in following path: fscache_alloc_object 1) cachefiles_alloc_object -> fscache_object_init -> assign cookie, but usage not bumped. 2) fscache_attach_object -> fails in cant_attach_object because the cookie's backing object or cookie's->parent object are going away 3) fscache_put_object -> cachefiles_put_object ->fscache_object_destroy ->fscache_cookie_put ->BUG_ON(atomic_read(&cookie->usage) <= 0); [NOTE from dhowells] It's unclear as to the circumstances in which (2) can take place, given that thread (1) is in nfs_kill_super(), however a conflicting NFS mount with slightly different parameters that creates a different superblock would do it. A backtrace from Kiran seems to show that this is a possibility: kernel BUG at/build/linux-Y09MKI/linux-4.4.0/fs/fscache/cookie.c:639! ... RIP: __fscache_cookie_put+0x3a/0x40 [fscache] Call Trace: __fscache_relinquish_cookie+0x87/0x120 [fscache] nfs_fscache_release_super_cookie+0x2d/0xb0 [nfs] nfs_kill_super+0x29/0x40 [nfs] deactivate_locked_super+0x48/0x80 deactivate_super+0x5c/0x60 cleanup_mnt+0x3f/0x90 __cleanup_mnt+0x12/0x20 task_work_run+0x86/0xb0 exit_to_usermode_loop+0xc2/0xd0 syscall_return_slowpath+0x4e/0x60 int_ret_from_sys_call+0x25/0x9f [Fix] Bump up the cookie usage in fscache_object_init, when it is first being assigned a cookie atomically such that the cookie is added and bumped up if its refcount is not zero. Remove the assignment in fscache_attach_object(). [Testcase] I have run ~100 hours of NFS stress tests and not seen this bug recur. [Regression Potential] - Limited to fscache/cachefiles. Fixes: ccc4fc3d11e9 ("FS-Cache: Implement the cookie management part of the netfs API") Signed-off-by: Kiran Kumar Modukuri Signed-off-by: David Howells (backported from commit f29507ce66701084c39aeb1b0ae71690cbff3554) Signed-off-by: Daniel Axtens --- fs/cachefiles/bind.c | 3 ++- fs/fscache/cache.c | 2 +- fs/fscache/cookie.c | 7 ++++--- fs/fscache/object.c | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c index 6af790fc3df8..c49944b6d9fe 100644 --- a/fs/cachefiles/bind.c +++ b/fs/cachefiles/bind.c @@ -218,7 +218,8 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) "%s", fsdef->dentry->d_sb->s_id); - fscache_object_init(&fsdef->fscache, NULL, &cache->cache); + fscache_object_init(&fsdef->fscache, &fscache_fsdef_index, + &cache->cache); ret = fscache_add_cache(&cache->cache, &fsdef->fscache, cache->tag); if (ret < 0) diff --git a/fs/fscache/cache.c b/fs/fscache/cache.c index 56cce7fdd39e..a8fe6e63ca23 100644 --- a/fs/fscache/cache.c +++ b/fs/fscache/cache.c @@ -220,6 +220,7 @@ int fscache_add_cache(struct fscache_cache *cache, { struct fscache_cache_tag *tag; + ASSERTCMP(ifsdef->cookie, ==, &fscache_fsdef_index); BUG_ON(!cache->ops); BUG_ON(!ifsdef); @@ -248,7 +249,6 @@ int fscache_add_cache(struct fscache_cache *cache, if (!cache->kobj) goto error; - ifsdef->cookie = &fscache_fsdef_index; ifsdef->cache = cache; cache->fsdef = ifsdef; diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c index 40d61077bead..91f56e066971 100644 --- a/fs/fscache/cookie.c +++ b/fs/fscache/cookie.c @@ -302,6 +302,7 @@ static int fscache_alloc_object(struct fscache_cache *cache, goto error; } + ASSERTCMP(object->cookie, ==, cookie); fscache_stat(&fscache_n_object_alloc); object->debug_id = atomic_inc_return(&fscache_object_debug_id); @@ -357,6 +358,8 @@ static int fscache_attach_object(struct fscache_cookie *cookie, _enter("{%s},{OBJ%x}", cookie->def->name, object->debug_id); + ASSERTCMP(object->cookie, ==, cookie); + spin_lock(&cookie->lock); /* there may be multiple initial creations of this object, but we only @@ -396,9 +399,7 @@ static int fscache_attach_object(struct fscache_cookie *cookie, spin_unlock(&cache->object_list_lock); } - /* attach to the cookie */ - object->cookie = cookie; - atomic_inc(&cookie->usage); + /* Attach to the cookie. The object already has a ref on it. */ hlist_add_head(&object->cookie_link, &cookie->backing_objects); fscache_objlist_add(object); diff --git a/fs/fscache/object.c b/fs/fscache/object.c index 7a182c87f378..4ae441f65af2 100644 --- a/fs/fscache/object.c +++ b/fs/fscache/object.c @@ -318,6 +318,7 @@ void fscache_object_init(struct fscache_object *object, object->store_limit_l = 0; object->cache = cache; object->cookie = cookie; + atomic_inc(&cookie->usage); object->parent = NULL; #ifdef CONFIG_FSCACHE_OBJECT_LIST RB_CLEAR_NODE(&object->objlist_link); From patchwork Thu Aug 2 04:18:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 952565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41gxkN4CXwz9rxx; Thu, 2 Aug 2018 14:18:36 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fl54H-0007GF-MG; Thu, 02 Aug 2018 04:18:29 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fl54F-0007EU-Ga for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:27 +0000 Received: from mail-pl0-f70.google.com ([209.85.160.70]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fl54F-0001uv-22 for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:27 +0000 Received: by mail-pl0-f70.google.com with SMTP id r16-v6so586093pls.21 for ; Wed, 01 Aug 2018 21:18:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=v25LfUWtIwUC6Q9FVUZAlSta0bDbHM/6+deo2/PWsQQ=; b=j1sn7g4fHJrvL8xudjvrtOsRXSe9ovijJgvq/aokjmnvB1mScy0xw7lN+O+YQs/FSc teeTQwsRp03x4V7CAcOTnhdPpHEvuNTv+1vfMqxRFIcLE5pze4ykjAMUrTJzPmvJt4vg 0G08AmhyTrbI7Afafyf+78wYmjzLGm/Y8nkpIf8s0uxwIUanmWuHHTxxHxV9PQW/zRPY XQ/qFblS4+/sQyD56yeJF5D4QSLxjMcSx1HL4QCgWxFTShelmiH+KJFVt6joPhHiQe/a 8FKVX8UcaaF+YgzmghRyisEjpZh+qM9qAWpitR/vx34X3n+G6gAVh3jBqJTBDV7azIPw LQ+Q== X-Gm-Message-State: AOUpUlGuZ/r3XmpawUWelDvdNX1wjetuMbLJ256gjaBaoS9IO0p1qvsb +ziCbyonz5yD81GbkMjoWCxZ/vAEY31+ZHsDu5rbwcpad9Ostq6coVFXgNKq1E+0PqaMi/gXpvL J8sh3FLna4nHFrvdDw3aOPJyHPk/C0nD7eOYvY5TB3vYwrpzq X-Received: by 2002:a17:902:7898:: with SMTP id q24-v6mr932382pll.222.1533183505744; Wed, 01 Aug 2018 21:18:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdexi4aiVartsGezKPcRxDCKCcHeg4yU7h90pqvWCRGsA8yBcX5r1qY44x83+hCY55pvkT5qA== X-Received: by 2002:a17:902:7898:: with SMTP id q24-v6mr932376pll.222.1533183505589; Wed, 01 Aug 2018 21:18:25 -0700 (PDT) Received: from localhost.localdomain (124-171-193-200.dyn.iinet.net.au. [124.171.193.200]) by smtp.gmail.com with ESMTPSA id t186-v6sm639186pgd.77.2018.08.01.21.18.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 21:18:25 -0700 (PDT) From: Daniel Axtens To: kernel-team@lists.canonical.com Subject: [SRU X][PATCH 5/6] cachefiles: Fix missing clear of the CACHEFILES_OBJECT_ACTIVE flag Date: Thu, 2 Aug 2018 14:18:09 +1000 Message-Id: <20180802041810.22748-6-daniel.axtens@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802041810.22748-1-daniel.axtens@canonical.com> References: <20180802041810.22748-1-daniel.axtens@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kiran Kumar Modukuri BugLink: https://bugs.launchpad.net/bugs/1776254 In cachefiles_mark_object_active(), the new object is marked active and then we try to add it to the active object tree. If a conflicting object is already present, we want to wait for that to go away. After the wait, we go round again and try to re-mark the object as being active - but it's already marked active from the first time we went through and a BUG is issued. Fix this by clearing the CACHEFILES_OBJECT_ACTIVE flag before we try again. Analysis from Kiran Kumar Modukuri: [Impact] Oops during heavy NFS + FSCache + Cachefiles CacheFiles: Error: Overlong wait for old active object to go away. BUG: unable to handle kernel NULL pointer dereference at 0000000000000002 CacheFiles: Error: Object already active kernel BUG at fs/cachefiles/namei.c:163! [Cause] In a heavily loaded system with big files being read and truncated, an fscache object for a cookie is being dropped and a new object being looked. The new object being looked for has to wait for the old object to go away before the new object is moved to active state. [Fix] Clear the flag 'CACHEFILES_OBJECT_ACTIVE' for the new object when retrying the object lookup. [Testcase] Have run ~100 hours of NFS stress tests and have not seen this bug recur. [Regression Potential] - Limited to fscache/cachefiles. Fixes: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem") Signed-off-by: Kiran Kumar Modukuri Signed-off-by: David Howells (backported from commit 5ce83d4bb7d8e11e8c1c687d09f4b5ae67ef3ce3) Signed-off-by: Daniel Axtens --- fs/cachefiles/namei.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index c4b893453e0e..2bb1bae8d3bc 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -190,6 +190,8 @@ try_again: /* an old object from a previous incarnation is hogging the slot - we * need to wait for it to be destroyed */ wait_for_old_object: + clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags); + if (fscache_object_is_live(&xobject->fscache)) { pr_err("\n"); pr_err("Error: Unexpected object collision\n"); @@ -251,7 +253,6 @@ wait_for_old_object: goto try_again; requeue: - clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags); cache->cache.ops->put_object(&xobject->fscache); _leave(" = -ETIMEDOUT"); return -ETIMEDOUT; From patchwork Thu Aug 2 04:18:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 952566 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41gxkP3wWvz9s2g; Thu, 2 Aug 2018 14:18:37 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fl54I-0007HJ-Ql; Thu, 02 Aug 2018 04:18:30 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fl54H-0007Ft-A3 for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:29 +0000 Received: from mail-pl0-f69.google.com ([209.85.160.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fl54G-0001v5-UF for kernel-team@lists.canonical.com; Thu, 02 Aug 2018 04:18:29 +0000 Received: by mail-pl0-f69.google.com with SMTP id j1-v6so582406pld.23 for ; Wed, 01 Aug 2018 21:18:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=B1uwI4kdr+rd+Q2XPabacc5alKmpqMPXIebQsp0KEHg=; b=i+TDRNCEQovGQJLoRPxRe90wOyUgBLf6fR82llMGl9OkrWNWjv6aBoxuN1lLlKunUd BQp+AQP+d4vTXdHRFbFg9morniiTfMh7T1Qa1+xxPYDgWyw8Mat9W/sjemLHN3cKSFzL QOnwDZU6aXH5aq+oIgxyyzACwLDv9wLbt9nN1HsN3WxXtMHpZE2RgNTRbqGL5GPT2aXs jHNoMEJWaneKVQY43tiDxxZHNyS6NIYfuSUsFtfgIiZEpDLXwzTCQK9gPD+D5r4r/AbL EymdKvOuaJwKUKAq0VFiXpuSNbY058RlD2wgVObQjmTwD+uR2gsTpdR6pfaFXCRrVYsn NBwQ== X-Gm-Message-State: AOUpUlF1HyzOBad4+5CZW3e0D2/cfGy13ERqmBUj+S5hQbq/QQHL7qbw wBgGYYC/Tg37SYvur+GIUFYpLF3N2mtRytBb/s8t2nzpgBTyw7RLXRiUUbSQn1Sobsqz6mrVJhF 7nrD0Afs+gS5vwpxk/YYL6V0L4mz8epaMi12fY+B7LTfgw6rE X-Received: by 2002:a63:5a5e:: with SMTP id k30-v6mr1115014pgm.123.1533183507654; Wed, 01 Aug 2018 21:18:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeOZ6Ct8etMoO7UEGpyS64Zkbx2RMZjJAxR0GUDCsgMb25ErPAUsnKlxDqEqnXHKWKSifDlzQ== X-Received: by 2002:a63:5a5e:: with SMTP id k30-v6mr1115009pgm.123.1533183507522; Wed, 01 Aug 2018 21:18:27 -0700 (PDT) Received: from localhost.localdomain (124-171-193-200.dyn.iinet.net.au. [124.171.193.200]) by smtp.gmail.com with ESMTPSA id t186-v6sm639186pgd.77.2018.08.01.21.18.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 21:18:27 -0700 (PDT) From: Daniel Axtens To: kernel-team@lists.canonical.com Subject: [SRU X][PATCH 6/6] cachefiles: Wait rather than BUG'ing on "Unexpected object collision" Date: Thu, 2 Aug 2018 14:18:10 +1000 Message-Id: <20180802041810.22748-7-daniel.axtens@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802041810.22748-1-daniel.axtens@canonical.com> References: <20180802041810.22748-1-daniel.axtens@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kiran Kumar Modukuri BugLink: https://bugs.launchpad.net/bugs/1776254 If we meet a conflicting object that is marked FSCACHE_OBJECT_IS_LIVE in the active object tree, we have been emitting a BUG after logging information about it and the new object. Instead, we should wait for the CACHEFILES_OBJECT_ACTIVE flag to be cleared on the old object (or return an error). The ACTIVE flag should be cleared after it has been removed from the active object tree. A timeout of 60s is used in the wait, so we shouldn't be able to get stuck there. Fixes: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem") Signed-off-by: Kiran Kumar Modukuri Signed-off-by: David Howells (cherry picked from commit c2412ac45a8f8f1cd582723c1a139608694d410d) Signed-off-by: Daniel Axtens --- fs/cachefiles/namei.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 2bb1bae8d3bc..2cd5b7ac3613 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -196,7 +196,6 @@ wait_for_old_object: pr_err("\n"); pr_err("Error: Unexpected object collision\n"); cachefiles_printk_object(object, xobject); - BUG(); } atomic_inc(&xobject->usage); write_unlock(&cache->active_lock);