From patchwork Fri Jan 29 18:34:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 8166451 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D6F3FBEEE5 for ; Fri, 29 Jan 2016 18:34:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E3EEE20389 for ; Fri, 29 Jan 2016 18:34:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB44420374 for ; Fri, 29 Jan 2016 18:34:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756716AbcA2Seg (ORCPT ); Fri, 29 Jan 2016 13:34:36 -0500 Received: from mx2.suse.de ([195.135.220.15]:50065 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756674AbcA2Sef (ORCPT ); Fri, 29 Jan 2016 13:34:35 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 04DDEABB4; Fri, 29 Jan 2016 18:34:34 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 4AA6DDA9E7; Fri, 29 Jan 2016 19:34:22 +0100 (CET) Date: Fri, 29 Jan 2016 19:34:22 +0100 From: David Sterba To: Filipe Manana Cc: David Sterba , "linux-btrfs@vger.kernel.org" Subject: Re: [PATCH 3/4] btrfs: sysfs: introduce helper for syncing bits with sysfs files Message-ID: <20160129183422.GE31992@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Filipe Manana , David Sterba , "linux-btrfs@vger.kernel.org" References: <444e75169872f668eb890f19ec1f32dfc632e704.1453400624.git.dsterba@suse.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 On Fri, Jan 29, 2016 at 01:55:31PM +0000, Filipe Manana wrote: > Did you try to run all xfstests with this? > > I'm getting very often lots of warnings in btrfs tests 060 to 074: Could you please test the attached patch in your testing setup? I was not able to trigger the crashes with btrfs/060 062 063, running hundreds of times with concurrent "find /sys/fs/btrfs -exec cat '{}' \;" in a tight loop. Out of all approaches how update the sysfs files, the one based on workques looks best to me. The allocation context is safe wrt internal sysfs allocations with GFP_KERNEL. ----------------------------8<------------------------------- From: David Sterba Subject: [PATCH] btrfs: sysfs: update features from a workqueue Signed-off-by: David Sterba --- fs/btrfs/sysfs.c | 37 +++++++++++++++++++++++++++++++------ fs/btrfs/sysfs.h | 7 +++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 539e7b5e3f86..ced2570fdf6a 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -782,12 +782,7 @@ failure: return error; } - -/* - * Change per-fs features in /sys/fs/btrfs/UUID/features to match current - * values in superblock. Call after any changes to incompat/compat_ro flags - */ -void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, +static void btrfs_sysfs_do_feature_update(struct btrfs_fs_info *fs_info, u64 bit, enum btrfs_feature_set set) { struct btrfs_fs_devices *fs_devs; @@ -815,6 +810,36 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, ret = sysfs_create_group(fsid_kobj, &btrfs_feature_attr_group); } +static void btrfs_sysfs_feature_update_callback(struct work_struct *work) +{ + struct btrfs_feature_update *bfu = container_of(work, + struct btrfs_feature_update, work); + + btrfs_sysfs_do_feature_update(bfu->fs_info, bfu->bit, bfu->set); + kfree(bfu); +} + +/* + * Change per-fs features in /sys/fs/btrfs/UUID/features to match current + * values in superblock. Call after any changes to incompat/compat_ro flags + */ +void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, + u64 bit, enum btrfs_feature_set set) +{ + struct btrfs_feature_update *bfu; + + bfu = kmalloc(sizeof(*bfu), GFP_NOFS); + if (!bfu) + return; + + INIT_WORK(&bfu->work, btrfs_sysfs_feature_update_callback); + bfu->fs_info = fs_info; + bfu->bit = bit; + bfu->set = set; + + schedule_work(&bfu->work); +} + static int btrfs_init_debugfs(void) { #ifdef CONFIG_DEBUG_FS diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index d7da1a4c2f6c..d9772f2e5c9a 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h @@ -93,4 +93,11 @@ void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs); void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, u64 bit, enum btrfs_feature_set set); +struct btrfs_feature_update { + struct work_struct work; + struct btrfs_fs_info *fs_info; + u64 bit; + enum btrfs_feature_set set; +}; + #endif /* _BTRFS_SYSFS_H_ */