From patchwork Wed Nov 7 20:10:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10673009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF9AD109C for ; Wed, 7 Nov 2018 20:11:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B37C82D082 for ; Wed, 7 Nov 2018 20:11:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A72D62D07F; Wed, 7 Nov 2018 20:11:02 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 510EC2D027 for ; Wed, 7 Nov 2018 20:11:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726455AbeKHFm4 (ORCPT ); Thu, 8 Nov 2018 00:42:56 -0500 Received: from mail-yb1-f196.google.com ([209.85.219.196]:39476 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726421AbeKHFm4 (ORCPT ); Thu, 8 Nov 2018 00:42:56 -0500 Received: by mail-yb1-f196.google.com with SMTP id j9-v6so7362611ybj.6 for ; Wed, 07 Nov 2018 12:11:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=6Cqsuh4GIonb8tyhsJgmuoTO5Ga1aCLg0swZa5FOLKI=; b=HDJJ73YQ+pl/Jk7etwG5CodNfJiAIaxoWKriUcQhSoZ1DUfi72y+r40fYDF1trYV1U rb6H+AcOHamHrhan1Dsm/zMotHlSX4TGi3sdNLg8/o08SqBAl4m6xQEgdAkHRT6HCpw+ 1Iqpw8bBAwTzKJgXbwKDWReZoBeHrwVdRx1hqtznJXsHU0QiYf9qX8MOoYrnAU4RU5zp qFcqNNqS+8nLGYZBhzsuwueFb0OU4uOqyez/Xju3fNvC8HbFLI2rDi/sdidoUwnOPFm5 NVeWQPvb866W5PCUuy3Cr5ufqxfTuzMRQ17lQcS7q/MkjqiUByKdtLsvan99t8mFZNg0 pipw== 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=6Cqsuh4GIonb8tyhsJgmuoTO5Ga1aCLg0swZa5FOLKI=; b=neiz2iMWbhE7fAxX1Bu6jQwsSeVvXVhOJj5Y+5QGBt6qRhEKy0BOrrZ9EIOm6PcRPp H3p9QuOtyMSYp46b58wcKCll5yeKFJm6113k6GcrA5QdtK28LgrGXWMkMBQSBTZvOoL5 +Ts4kWmswz044PI1GlHfWqERUtrdelAgG/d49C126C/AeqsN3/QRSAholepguIBCCjUB EzAKQB29OXZuvN0WKeRu2bJBE8A6RSvKA2otdz2Urply/vdWjvEXElvh4JSAaatmJBbD 5ur/92N5z70mMicjsoToBW6csj5PYI5tFN4lXkjqVvPzQLKCIm/ffa/QrCWH+hQhHcHK 5h6g== X-Gm-Message-State: AGRZ1gJkWYJ7qhdDFH2HZ+rrTUXXHjyKVEkgYShtDlLOkokH00dyu3aL oqZswTSLnpUXO4Oj79ASSBnEmrRNBsKxGA== X-Google-Smtp-Source: AJdET5f598gNLFEZ2H/+NIheE/g+8BeXGRjIIiFqxVr0Fc5YsYlpF0PR+jQfoQ3yFb4QqJe8gl3QKA== X-Received: by 2002:a25:1009:: with SMTP id 9-v6mr1713769ybq.487.1541621460889; Wed, 07 Nov 2018 12:11:00 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id k82-v6sm746545ywb.65.2018.11.07.12.11.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Nov 2018 12:11:00 -0800 (PST) From: Josef Bacik To: kernel-team@fb.com, linux-xfs@vger.kernel.org Subject: [PATCH 1/2] xfs: change xfs_buf_ioapply_map to STATIC Date: Wed, 7 Nov 2018 15:10:54 -0500 Message-Id: <20181107201055.25883-2-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181107201055.25883-1-josef@toxicpanda.com> References: <20181107201055.25883-1-josef@toxicpanda.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to make error injection triggering easier make xfs_buf_ioapply_map STATIC so it's noinline and can be kprobe'ed. Signed-off-by: Josef Bacik --- fs/xfs/xfs_buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index b21ea2ba768d..341bdb55b650 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -1327,7 +1327,7 @@ xfs_buf_bio_end_io( bio_put(bio); } -static void +STATIC void xfs_buf_ioapply_map( struct xfs_buf *bp, int map, From patchwork Wed Nov 7 20:10:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10673011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5931A15A6 for ; Wed, 7 Nov 2018 20:11:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49BEC2D089 for ; Wed, 7 Nov 2018 20:11:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4825E2D08C; Wed, 7 Nov 2018 20:11:04 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 D9E562D089 for ; Wed, 7 Nov 2018 20:11:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726421AbeKHFm6 (ORCPT ); Thu, 8 Nov 2018 00:42:58 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:35267 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726352AbeKHFm6 (ORCPT ); Thu, 8 Nov 2018 00:42:58 -0500 Received: by mail-yw1-f66.google.com with SMTP id w135-v6so7110231ywd.2 for ; Wed, 07 Nov 2018 12:11:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=/SnCZz2JVALTjxfzUwHMbk8Ma3aTAHq7NyxpBNAJB2w=; b=zMYWdQDIx9S0ApCc6HHGIKX4laXjLknssaXEuLEajynrcIWhp+YimRyZiJSKnHM55W HuoZGVUa1jXwFLDUP+QOSf7wvvIfrgYU6gJKyhMnGBoZGOsxWohp9qtSZuICOfdR+Zub CRmZbxz+xc/UJM/vfRF0lMGQWmAJvLy+juSCG0bmdGFHzESZytMBLxr7ys2KaMFbjFJd Bu6hdw4SL1VmuIziwjXZ3BMG4WsE7KoMPPPOMzgE/e9b1S3uCG6gS4NRD/klDXhIgqsZ HFM4yWasCZhh4HsdwXLApi1OI1fcXJIIoZd9k9tagyzCtlNs3/061Ct4jGwZVpLe8Ubz /e8A== 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=/SnCZz2JVALTjxfzUwHMbk8Ma3aTAHq7NyxpBNAJB2w=; b=Qqxb5wxCqqpPAf9RtqHUDTSPQ0X8C+fd1dZc2IADGoSasyqaHtwQvsxdAVo0E8duGc 96Wd9Hb48tp+T6N41Rx5CpycJTETiW+g3B44igeZ8Vr6yQe/9T4V0t2avW0iYzcaiw/H jyGkH3HQqyMHF5ZXu/RTmY3FGAzgj+CDW3pXm4DpzH0SK7GfgCTdpsT93cBOvjkCcaTc Aqm2DtVjUeJyQOx8fpQnm6i1/sVt58QKrQ9I/ObFKpYDJqs45UDct+/2G1EyFcjIZ72a JX+sKJD0sr136Guo2wq23K68MCoGIYFEfWv88HLaZhvxXgrcZ50GFx9qGq67KYVJ9Jvf 8RJA== X-Gm-Message-State: AGRZ1gL/aP3BGi8nX6VEJyIrD6lsCYWmY8fA3hl65IaEL0ySVAMRyCoK 1MVqps/V568UsdeKKKP/MTzPow== X-Google-Smtp-Source: AJdET5dzLeUSOxSFt/d16p/1gBLLF4jshLlmJnWeA9zaaJ5cBMkXUhOi2ba5Hm+cvpEaoQ6/i8b+LQ== X-Received: by 2002:a0d:f385:: with SMTP id c127-v6mr1712700ywf.10.1541621462250; Wed, 07 Nov 2018 12:11:02 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id v5-v6sm405488ywb.62.2018.11.07.12.11.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Nov 2018 12:11:01 -0800 (PST) From: Josef Bacik To: kernel-team@fb.com, linux-xfs@vger.kernel.org Subject: [PATCH 2/2] xfs: take a ref on failed bufs in xfs_inode_item_push Date: Wed, 7 Nov 2018 15:10:55 -0500 Message-Id: <20181107201055.25883-3-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181107201055.25883-1-josef@toxicpanda.com> References: <20181107201055.25883-1-josef@toxicpanda.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we failed to writeout a xfs_buf we'll grab a ref for it and put it on li->li_buf. Then when submitting the failed bufs we'll clear LI_FAILED on the li, which clears the LI_FAILED flag, but also drops the ref on the buf. Since it isn't on a IO list at this point this could very well be the last ref on the buf, which wreaks havoc when we go to add the buf to the delwrite list. Fix this by holding a ref on the buf before we call xfs_buf_resubmit_failed_buffers in order to make sure the buf doesn't disappear before we're able to clear the error and add it to the delwri list. This fixes the panics I was seeing with error injection. Signed-off-by: Josef Bacik --- fs/xfs/xfs_inode_item.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index fa1c4fe2ffbf..df49adf1989c 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -503,13 +503,16 @@ xfs_inode_item_push( * previously. Resubmit the buffer for IO. */ if (test_bit(XFS_LI_FAILED, &lip->li_flags)) { - if (!xfs_buf_trylock(bp)) + xfs_buf_hold(bp); + if (!xfs_buf_trylock(bp)) { + xfs_buf_rele(bp); return XFS_ITEM_LOCKED; + } if (!xfs_buf_resubmit_failed_buffers(bp, buffer_list)) rval = XFS_ITEM_FLUSHING; - xfs_buf_unlock(bp); + xfs_buf_relse(bp); return rval; }