From patchwork Mon Jun 23 12:01:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4401391 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 91F929F1D6 for ; Mon, 23 Jun 2014 11:01:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B318201BB for ; Mon, 23 Jun 2014 11:01:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6E7032018E for ; Mon, 23 Jun 2014 11:01:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753524AbaFWLBb (ORCPT ); Mon, 23 Jun 2014 07:01:31 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:52489 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751767AbaFWLBa (ORCPT ); Mon, 23 Jun 2014 07:01:30 -0400 Received: by mail-wi0-f171.google.com with SMTP id n15so3990585wiw.10 for ; Mon, 23 Jun 2014 04:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kF2dAThklWQZZodXojfn9S+wj4Jy9g2ViblgcXcR/Qo=; b=zYXvB2kz2K0VDDuYFv4iQ77GbSSzZZA4O7ohAVo2NWfQk5N0JnmLej87h/+/kFFYLl igqVl76kCMtltVNMMigNBOGyeDFuyRiiGcmiqC3VdQt4PUuz7xXO+dk1/cy5gz7xxZEO BV6jE5GAGrUrvQq7EkvS/ak6rGo4h75WYBdt91eew5qWkFhrrJl2NL8f02wTaQ5n7JaM kbZjXMruw9r6cX7BbZilz/Edunn6MCXqGofgjv8QE/RK/cFKsxSOg/bu7cLGhS+fejri hiRJhoOr8k5aT1Sef/LIvadMwdMQ2j631kHyvIgPyfvlOUsYgriYWrNqL/BWxz59Ked/ BdpA== X-Received: by 10.194.88.199 with SMTP id bi7mr27133616wjb.79.1403521287012; Mon, 23 Jun 2014 04:01:27 -0700 (PDT) Received: from debian-vm3.lan (bl5-3-159.dsl.telepac.pt. [82.154.3.159]) by mx.google.com with ESMTPSA id u10sm32363647wix.11.2014.06.23.04.01.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jun 2014 04:01:26 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH 5/6 v5] Btrfs: add missing cleanup on sysfs init failure Date: Mon, 23 Jun 2014 13:01:11 +0100 Message-Id: <1403524871-2131-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1398002808-11080-1-git-send-email-fdmanana@gmail.com> References: <1398002808-11080-1-git-send-email-fdmanana@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 If we failed during initialization of sysfs, we weren't unregistering the top level btrfs sysfs entry nor the debugfs stuff. Not unregistering the top level sysfs entry makes future attempts to reload the btrfs module impossible and the following is reported in dmesg: [ 2246.451296] WARNING: CPU: 3 PID: 10999 at fs/sysfs/dir.c:486 sysfs_warn_dup+0x91/0xb0() [ 2246.451298] sysfs: cannot create duplicate filename '/fs/btrfs' [ 2246.451298] Modules linked in: btrfs(+) raid6_pq xor bnep rfcomm bluetooth binfmt_misc nfsd auth_rpcgss oid_registry nfs_acl nfs lockd fscache sunrpc parport_pc parport psmouse serio_raw pcspkr evbug i2c_piix4 e1000 floppy [last unloaded: btrfs] [ 2246.451310] CPU: 3 PID: 10999 Comm: modprobe Tainted: G W 3.13.0-fdm-btrfs-next-24+ #7 [ 2246.451311] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 2246.451312] 0000000000000009 ffff8800d353fa08 ffffffff816f1da6 0000000000000410 [ 2246.451314] ffff8800d353fa58 ffff8800d353fa48 ffffffff8104a32c ffff88020821a290 [ 2246.451316] ffff88020821a290 ffff88020821a290 ffff8802148f0000 ffff8800d353fb80 [ 2246.451318] Call Trace: [ 2246.451322] [] dump_stack+0x4e/0x68 [ 2246.451324] [] warn_slowpath_common+0x8c/0xc0 [ 2246.451325] [] warn_slowpath_fmt+0x46/0x50 [ 2246.451328] [] ? strlcat+0x65/0x90 (....) Signed-off-by: Filipe David Borba Manana Reviewed-by: Satoru Takeuchi --- V1..V4: There's no v1, v2, v3 and v4. Bumped directly to v5 to make all patches in the series have the same version. V5: Rebased against latest chris/integration branch. fs/btrfs/sysfs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index df39458..06ad529 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -710,10 +710,18 @@ int btrfs_init_sysfs(void) ret = btrfs_init_debugfs(); if (ret) - return ret; + goto out1; init_feature_attrs(); ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_feature_attr_group); + if (ret) + goto out2; + + return 0; +out2: + debugfs_remove_recursive(btrfs_debugfs_root_dentry); +out1: + kset_unregister(btrfs_kset); return ret; }