From patchwork Mon Nov 18 08:46:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249125 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 727F614DB for ; Mon, 18 Nov 2019 08:47:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 48FFC20748 for ; Mon, 18 Nov 2019 08:47:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="lA0HQPW3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726461AbfKRIrI (ORCPT ); Mon, 18 Nov 2019 03:47:08 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:47990 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbfKRIrI (ORCPT ); Mon, 18 Nov 2019 03:47:08 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iNgZ105641 for ; Mon, 18 Nov 2019 08:47:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=P05tu+xpF3YKGliIXO+MSkpkyem0W8pkrpCYNAOqUq4=; b=lA0HQPW3lXRX6mSDznm1m2eLoKWVp475w4/i2/STWTBTrCgrwgXRhoco3tqMaGlKsBYA SkLpxKK3Cp78sAMgrdlksg/+EEmeQ1RQUA97u6JYeR3D0ZoS1114662FNA/kpSOzJ2RB 6QzZcKqqqy4eo6XKE9RpHUjRDUfoR8uBv3YXQ44Rvte2CU/TO+4k1bsZ/qPw6c5Kf1Y7 0NcLP9X3dFefDWgsSAdbU6BdEr9kjQXTe8yBsV9N69iH0PnDN8F6cvajk4i6vT2ryz7q naOmO6vXYO4GRUZTRga1SP8jbz4tTE3Yu/67pUxqOh6cjxtzUnmH3/Ra2hKQi/r3iWWT bA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2wa8htenpn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:06 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i2u3156200 for ; Mon, 18 Nov 2019 08:47:05 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2wau946cxs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:05 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAI8l4UN010634 for ; Mon, 18 Nov 2019 08:47:04 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:03 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 01/15] btrfs: sysfs, rename device_link add,remove functions Date: Mon, 18 Nov 2019 16:46:42 +0800 Message-Id: <20191118084656.3089-2-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In preparation to add btrfs_device::dev_state attribute in /sys/fs/btrfs/UUID/devices/ Rename btrfs_sysfs_add_device_link() and btrfs_sysfs_rm_device_link() to btrfs_sysfs_add_device_info() and btrfs_sysfs_remove_device_info() as these functions is going to create more attributes rather than just the link to the disk. No functional changes. Signed-off-by: Anand Jain --- fs/btrfs/dev-replace.c | 4 ++-- fs/btrfs/sysfs.c | 10 +++++----- fs/btrfs/sysfs.h | 4 ++-- fs/btrfs/volumes.c | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index f639dde2a679..8184ddad28cf 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -472,7 +472,7 @@ static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, atomic64_set(&dev_replace->num_uncorrectable_read_errors, 0); up_write(&dev_replace->rwsem); - ret = btrfs_sysfs_add_device_link(tgt_device->fs_devices, tgt_device); + ret = btrfs_sysfs_add_device_info(tgt_device->fs_devices, tgt_device); if (ret) btrfs_err(fs_info, "kobj add dev failed %d", ret); @@ -706,7 +706,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, mutex_unlock(&fs_info->fs_devices->device_list_mutex); /* replace the sysfs entry */ - btrfs_sysfs_rm_device_link(fs_info->fs_devices, src_device); + btrfs_sysfs_remove_device_info(fs_info->fs_devices, src_device); btrfs_rm_dev_replace_free_srcdev(src_device); /* write back the superblocks */ diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 343d535a8081..76ee266f0b8d 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -784,7 +784,7 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) addrm_unknown_feature_attrs(fs_info, false); sysfs_remove_group(&fs_info->fs_devices->fsid_kobj, &btrfs_feature_attr_group); sysfs_remove_files(&fs_info->fs_devices->fsid_kobj, btrfs_attrs); - btrfs_sysfs_rm_device_link(fs_info->fs_devices, NULL); + btrfs_sysfs_remove_device_info(fs_info->fs_devices, NULL); } static const char * const btrfs_feature_set_names[FEAT_MAX] = { @@ -973,7 +973,7 @@ int btrfs_sysfs_add_space_info_type(struct btrfs_fs_info *fs_info, /* when one_device is NULL, it removes all device links */ -int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices, +int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device) { struct hd_struct *disk; @@ -1019,7 +1019,7 @@ int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs) return 0; } -int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices, +int btrfs_sysfs_add_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device) { int error = 0; @@ -1105,13 +1105,13 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) btrfs_set_fs_info_ptr(fs_info); - error = btrfs_sysfs_add_device_link(fs_devs, NULL); + error = btrfs_sysfs_add_device_info(fs_devs, NULL); if (error) return error; error = sysfs_create_files(fsid_kobj, btrfs_attrs); if (error) { - btrfs_sysfs_rm_device_link(fs_devs, NULL); + btrfs_sysfs_remove_device_info(fs_devs, NULL); return error; } diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index e10c3adfc30f..4b624e7d97c1 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h @@ -14,9 +14,9 @@ enum btrfs_feature_set { char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags); const char * const btrfs_feature_set_name(enum btrfs_feature_set set); -int btrfs_sysfs_add_device_link(struct btrfs_fs_devices *fs_devices, +int btrfs_sysfs_add_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device); -int btrfs_sysfs_rm_device_link(struct btrfs_fs_devices *fs_devices, +int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device); int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs, struct kobject *parent); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index d8e5560db285..40d77b5846dc 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2012,7 +2012,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, if (device->bdev) { cur_devices->open_devices--; /* remove sysfs entry */ - btrfs_sysfs_rm_device_link(fs_devices, device); + btrfs_sysfs_remove_device_info(fs_devices, device); } num_devices = btrfs_super_num_devices(fs_info->super_copy) - 1; @@ -2133,7 +2133,7 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_device *tgtdev) WARN_ON(!tgtdev); mutex_lock(&fs_devices->device_list_mutex); - btrfs_sysfs_rm_device_link(fs_devices, tgtdev); + btrfs_sysfs_remove_device_info(fs_devices, tgtdev); if (tgtdev->bdev) fs_devices->open_devices--; @@ -2481,7 +2481,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path orig_super_num_devices + 1); /* add sysfs device entry */ - btrfs_sysfs_add_device_link(fs_devices, device); + btrfs_sysfs_add_device_info(fs_devices, device); /* * we've got more storage, clear any full flags on the space @@ -2549,7 +2549,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path return ret; error_sysfs: - btrfs_sysfs_rm_device_link(fs_devices, device); + btrfs_sysfs_remove_device_info(fs_devices, device); mutex_lock(&fs_info->fs_devices->device_list_mutex); mutex_lock(&fs_info->chunk_mutex); list_del_rcu(&device->dev_list); From patchwork Mon Nov 18 08:46:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249127 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F03214DB for ; Mon, 18 Nov 2019 08:47:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6EDB120740 for ; Mon, 18 Nov 2019 08:47:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="OmiQVHPf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726490AbfKRIrK (ORCPT ); Mon, 18 Nov 2019 03:47:10 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:47558 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbfKRIrK (ORCPT ); Mon, 18 Nov 2019 03:47:10 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iOZQ094169 for ; Mon, 18 Nov 2019 08:47:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=CGnq32Ivd/twgu8kzg/T9TaNUxZaHhwDceD2Wm4eE28=; b=OmiQVHPfPaZRwNuePa5pUT62NJOSj5GiigYmrc+rHF0KDdnCml8USETlG6hnnye8A1Xw pPz7TUOMbrftLtqPSVxgGttmQtJ3Ye/64q0Kf+lHCR3Mf4wfrx5eE0bgeDmuaaWjc8lS V1vVcZSE6T4GJ+odOwWgY6CBKYX0cGqSBUxMz7cKVENnOgbadS6eU3MlmYSEEN2jT/g/ u+9JUDKz2CdCg2oOGlpTXESiP3h2Z+xrjftnEZnZmOyBT4XOCqfNWrwFjZF2gZNiKjod y8wArC2C5Vw4lgFgX9eAQqBVlHOynpBLxrDZuYq5/hYPzOyRVYoFXCJzycqF3K62Abyu Tg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2wa92pek8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:08 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8hwIU021170 for ; Mon, 18 Nov 2019 08:47:07 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2wau8mtacj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:07 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xAI8l69K018801 for ; Mon, 18 Nov 2019 08:47:06 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:05 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 02/15] btrfs: sysfs, rename btrfs_sysfs_add_device() Date: Mon, 18 Nov 2019 16:46:43 +0800 Message-Id: <20191118084656.3089-3-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_sysfs_add_device() creates the directory /sys/fs/btrfs/UUID/devices but its function name is misleading. Rename it to btrfs_sysfs_add_devices_dir() instead. No functional changes. Signed-off-by: Anand Jain --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/sysfs.c | 2 +- fs/btrfs/sysfs.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index e0edfdc9c82b..72191c213ac4 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3089,7 +3089,7 @@ int __cold open_ctree(struct super_block *sb, goto fail_block_groups; } - ret = btrfs_sysfs_add_device(fs_devices); + ret = btrfs_sysfs_add_devices_dir(fs_devices); if (ret) { btrfs_err(fs_info, "failed to init sysfs device interface: %d", ret); diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 76ee266f0b8d..399b9c46790c 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1007,7 +1007,7 @@ int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, return 0; } -int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs) +int btrfs_sysfs_add_devices_dir(struct btrfs_fs_devices *fs_devs) { if (!fs_devs->device_dir_kobj) fs_devs->device_dir_kobj = kobject_create_and_add("devices", diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index 4b624e7d97c1..3dac8e163056 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h @@ -20,7 +20,7 @@ int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device); int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs, struct kobject *parent); -int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs); +int btrfs_sysfs_add_devices_dir(struct btrfs_fs_devices *fs_devs); void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs); void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices, const u8 *fsid); From patchwork Mon Nov 18 08:46:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249129 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2662B14DB for ; Mon, 18 Nov 2019 08:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06E5E20748 for ; Mon, 18 Nov 2019 08:47:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="CdOLikqC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbfKRIrM (ORCPT ); Mon, 18 Nov 2019 03:47:12 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48028 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726464AbfKRIrL (ORCPT ); Mon, 18 Nov 2019 03:47:11 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i5qR105268 for ; Mon, 18 Nov 2019 08:47:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=sV0W/6Zpjeyn8J6xzbbJL1by47YfLsxaZwHUPBIPmNU=; b=CdOLikqC/+53TsoHSKlc9IhIcZQ15GMGX/Waj6SC2ADTzH0J9dtS6py7DYm7EYTR2MAl dCMFBL3i00cp1mOS4hScKfBHVwe9X6FtjXdC8eZ+d2mzUHVu5cJPLP4J331MJ+UoXpw1 BezNy3UB6wyWBgM6N8G+jzWILRaPVtH0DB5XUWblRIUFeJzKWvKE9a+wLh9GIP4a7Pwf ErZgq5aNQC9rBuVvAI80KjuDk6Mpr/DCuzkO8vCvtWmbZQWMUJw4mTBIcMBgrLoIzyrC wirGgCG/NkPtT1zP9luK9XlANM7fKQHUGhh4Dc1+qZuLTOwKUBoQPSbc840oVrSd1hrE BA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2wa8htenpv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:09 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iNr8091218 for ; Mon, 18 Nov 2019 08:47:09 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2watjx33jn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:09 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAI8l87N010655 for ; Mon, 18 Nov 2019 08:47:08 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:08 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 03/15] btrfs: sysfs, rename btrfs_device member device_dir_kobj Date: Mon, 18 Nov 2019 16:46:44 +0800 Message-Id: <20191118084656.3089-4-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The struct member btrfs_device::device_dir_kobj holds the kobj of the sysfs directory /sys/fs/btrfs/UUID/devices, so rename its holder from device_dir_kobj to devices_dir_kobj. No functional changes. Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 28 ++++++++++++++-------------- fs/btrfs/volumes.h | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 399b9c46790c..1d58187a6b33 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -744,10 +744,10 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add) static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs) { - if (fs_devs->device_dir_kobj) { - kobject_del(fs_devs->device_dir_kobj); - kobject_put(fs_devs->device_dir_kobj); - fs_devs->device_dir_kobj = NULL; + if (fs_devs->devices_dir_kobj) { + kobject_del(fs_devs->devices_dir_kobj); + kobject_put(fs_devs->devices_dir_kobj); + fs_devs->devices_dir_kobj = NULL; } if (fs_devs->fsid_kobj.state_initialized) { @@ -979,15 +979,15 @@ int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, struct hd_struct *disk; struct kobject *disk_kobj; - if (!fs_devices->device_dir_kobj) + if (!fs_devices->devices_dir_kobj) return -EINVAL; if (one_device && one_device->bdev) { disk = one_device->bdev->bd_part; disk_kobj = &part_to_dev(disk)->kobj; - sysfs_remove_link(fs_devices->device_dir_kobj, - disk_kobj->name); + sysfs_remove_link(fs_devices->devices_dir_kobj, + disk_kobj->name); } if (one_device) @@ -1000,8 +1000,8 @@ int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, disk = one_device->bdev->bd_part; disk_kobj = &part_to_dev(disk)->kobj; - sysfs_remove_link(fs_devices->device_dir_kobj, - disk_kobj->name); + sysfs_remove_link(fs_devices->devices_dir_kobj, + disk_kobj->name); } return 0; @@ -1009,11 +1009,11 @@ int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, int btrfs_sysfs_add_devices_dir(struct btrfs_fs_devices *fs_devs) { - if (!fs_devs->device_dir_kobj) - fs_devs->device_dir_kobj = kobject_create_and_add("devices", - &fs_devs->fsid_kobj); + if (!fs_devs->devices_dir_kobj) + fs_devs->devices_dir_kobj = kobject_create_and_add("devices", + &fs_devs->fsid_kobj); - if (!fs_devs->device_dir_kobj) + if (!fs_devs->devices_dir_kobj) return -ENOMEM; return 0; @@ -1038,7 +1038,7 @@ int btrfs_sysfs_add_device_info(struct btrfs_fs_devices *fs_devices, disk = dev->bdev->bd_part; disk_kobj = &part_to_dev(disk)->kobj; - error = sysfs_create_link(fs_devices->device_dir_kobj, + error = sysfs_create_link(fs_devices->devices_dir_kobj, disk_kobj, disk_kobj->name); if (error) break; diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index fc1b564b9cfe..012e75f29fe0 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -255,7 +255,7 @@ struct btrfs_fs_devices { struct btrfs_fs_info *fs_info; /* sysfs kobjects */ struct kobject fsid_kobj; - struct kobject *device_dir_kobj; + struct kobject *devices_dir_kobj; struct completion kobj_unregister; }; From patchwork Mon Nov 18 08:46:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77AEF14DB for ; Mon, 18 Nov 2019 08:47:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5700420748 for ; Mon, 18 Nov 2019 08:47:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="YUsBZcKJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726539AbfKRIrO (ORCPT ); Mon, 18 Nov 2019 03:47:14 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48070 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726464AbfKRIrO (ORCPT ); Mon, 18 Nov 2019 03:47:14 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i45L105142 for ; Mon, 18 Nov 2019 08:47:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=HbAZ4jOO+LFC47kfgfDx00PWYczBj3E1aFUNOb9j2W4=; b=YUsBZcKJKmrh02eZJ8rVbZtQFzoyx9FJ8wAVEbkqvM5eJGaKM7bmBWBsJ0XpiJazemjR X0jARx6KkktVdXqTObK069v1XYrkWuH+AoSAPOwaYAKzYRYDHaZ5NkYMKEzaFC4QYDPi Z83pxtLuMC3+gfx0FIMeyvWhn31dO4oX0+GLJ0KDYGq0GeRAktqbFz5Bb6JoqGpUY1ul 6CaI/97HvKyLuigyBZU1Ks15fuhwLFMoI3KiacTNStU2TuSQENa/IJ8jgMN1UD6EUVTU MpxtYOBRI7Qzp6mkcjvQgmCwhQm9iuvSCD1rnjeKf4Y0WLxK3huiE/9NpXCoTtby6Bq5 CQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2wa8htenq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:12 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iIvS152679 for ; Mon, 18 Nov 2019 08:47:11 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2watmr3fyr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:11 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xAI8lBn6018823 for ; Mon, 18 Nov 2019 08:47:11 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:10 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 04/15] btrfs: sysfs, move declared struct near its use Date: Mon, 18 Nov 2019 16:46:45 +0800 Message-Id: <20191118084656.3089-5-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=778 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=838 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Move struct btrfs_feature_attr and struct raid_kobject near functions and defines where its used. No functional change. Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 1d58187a6b33..d54777d5c78e 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -19,18 +19,6 @@ #include "space-info.h" #include "block-group.h" -struct btrfs_feature_attr { - struct kobj_attribute kobj_attr; - enum btrfs_feature_set feature_set; - u64 feature_bit; -}; - -/* For raid type sysfs entries */ -struct raid_kobject { - u64 flags; - struct kobject kobj; -}; - #define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \ { \ .attr = { .name = __stringify(_name), .mode = _mode }, \ @@ -49,6 +37,12 @@ struct raid_kobject { #define BTRFS_ATTR_PTR(_prefix, _name) \ (&btrfs_attr_##_prefix##_##_name.attr) +struct btrfs_feature_attr { + struct kobj_attribute kobj_attr; + enum btrfs_feature_set feature_set; + u64 feature_bit; +}; + #define BTRFS_FEAT_ATTR(_name, _feature_set, _feature_prefix, _feature_bit) \ static struct btrfs_feature_attr btrfs_attr_features_##_name = { \ .kobj_attr = __INIT_KOBJ_ATTR(_name, S_IRUGO, \ @@ -394,6 +388,12 @@ static ssize_t global_rsv_reserved_show(struct kobject *kobj, } BTRFS_ATTR(allocation, global_rsv_reserved, global_rsv_reserved_show); +/* For raid type sysfs entries */ +struct raid_kobject { + u64 flags; + struct kobject kobj; +}; + #define to_space_info(_kobj) container_of(_kobj, struct btrfs_space_info, kobj) #define to_raid_kobj(_kobj) container_of(_kobj, struct raid_kobject, kobj) From patchwork Mon Nov 18 08:46:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249133 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1521D14ED for ; Mon, 18 Nov 2019 08:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E95BA20748 for ; Mon, 18 Nov 2019 08:47:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="Uw+xgzN/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726568AbfKRIrR (ORCPT ); Mon, 18 Nov 2019 03:47:17 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48120 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726464AbfKRIrQ (ORCPT ); Mon, 18 Nov 2019 03:47:16 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i4ST105082 for ; Mon, 18 Nov 2019 08:47:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=0pozGaWXsrTEUL6y/hsdLeMKepkUZoPsXDxQaWTnnm4=; b=Uw+xgzN/64zeLqmk5exhSRmG2RGh9/DWNsJQ48+ssdu9AZOzOyv9O2SPv+LgSeMtRzru SbMvuj/Onf+K7E6b8RbVzaM+vvvjMDXlIhEBvWoYKWl2HqgnnPaW+zzRVhHXcEm4aIkp a6W1mPCAQ8+d0yo/1B+9G1bf1oqrpn5gmIePRcVeNTLbFupN94krmxafXMmDkPChvM6i eGpaTFEWrNGt5XYtIv9TgpAXZqh/6MCs+AXqIceodx2LKimHi1PcvWdfpRTtZtmLIpiS 0xHQ6+DCEw0qh1PzjsDkuf0utkGAnklgr+crvbXL9apoqTHX53fn3sFGLbw69ogNW9TE aQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2wa8htenqg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:15 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iKZK152767 for ; Mon, 18 Nov 2019 08:47:14 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2watmr3gba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:14 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xAI8lD3q003100 for ; Mon, 18 Nov 2019 08:47:13 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:12 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 05/15] btrfs: sysfs, move /sys/fs/btrfs/UUID related functions together Date: Mon, 18 Nov 2019 16:46:46 +0800 Message-Id: <20191118084656.3089-6-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org No functional changes. Move functions to bring btrfs_sysfs_remove_fsid() and btrfs_sysfs_add_fsid() and its related functions together. Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 60 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index d54777d5c78e..370f30561001 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -742,36 +742,6 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add) return 0; } -static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs) -{ - if (fs_devs->devices_dir_kobj) { - kobject_del(fs_devs->devices_dir_kobj); - kobject_put(fs_devs->devices_dir_kobj); - fs_devs->devices_dir_kobj = NULL; - } - - if (fs_devs->fsid_kobj.state_initialized) { - kobject_del(&fs_devs->fsid_kobj); - kobject_put(&fs_devs->fsid_kobj); - wait_for_completion(&fs_devs->kobj_unregister); - } -} - -/* when fs_devs is NULL it will remove all fsid kobject */ -void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs) -{ - struct list_head *fs_uuids = btrfs_get_fs_uuids(); - - if (fs_devs) { - __btrfs_sysfs_remove_fsid(fs_devs); - return; - } - - list_for_each_entry(fs_devs, fs_uuids, fs_list) { - __btrfs_sysfs_remove_fsid(fs_devs); - } -} - void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) { btrfs_reset_fs_info_ptr(fs_info); @@ -1076,6 +1046,36 @@ void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices, /* /sys/fs/btrfs/ entry */ static struct kset *btrfs_kset; +static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs) +{ + if (fs_devs->devices_dir_kobj) { + kobject_del(fs_devs->devices_dir_kobj); + kobject_put(fs_devs->devices_dir_kobj); + fs_devs->devices_dir_kobj = NULL; + } + + if (fs_devs->fsid_kobj.state_initialized) { + kobject_del(&fs_devs->fsid_kobj); + kobject_put(&fs_devs->fsid_kobj); + wait_for_completion(&fs_devs->kobj_unregister); + } +} + +/* when fs_devs is NULL it will remove all fsid kobject */ +void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs) +{ + struct list_head *fs_uuids = btrfs_get_fs_uuids(); + + if (fs_devs) { + __btrfs_sysfs_remove_fsid(fs_devs); + return; + } + + list_for_each_entry(fs_devs, fs_uuids, fs_list) { + __btrfs_sysfs_remove_fsid(fs_devs); + } +} + /* * Can be called by the device discovery thread. * And parent can be specified for seed device From patchwork Mon Nov 18 08:46:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249135 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F61214ED for ; Mon, 18 Nov 2019 08:47:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EAA1620740 for ; Mon, 18 Nov 2019 08:47:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="b3ab3HFL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726579AbfKRIrT (ORCPT ); Mon, 18 Nov 2019 03:47:19 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:52786 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726552AbfKRIrS (ORCPT ); Mon, 18 Nov 2019 03:47:18 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iPv6077416 for ; Mon, 18 Nov 2019 08:47:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=EQa4J8uURlLZb7+mC4vxj6zWBoCDnNgEvN6dbIa3Vk0=; b=b3ab3HFLzw4NbeyXWGJIhWx/oM0uUwEytTGmcQdQPOa4uDAIBitb3ARHXmkBuu34LQlP X1rIhOFci0mZd7mxyVWTONzJd56hC8MV8rpsVQe1/mJM3PcVRG1QPEG12V3zbaj+vnwE FVifJtLtQITmBdHDtmqOZGTrKKUh8oSqiIXHrrPQtx69B68MUOAxwohEE104SuWDNZsM GPRaopfy9oUUtaNXv7a7eLFSaZ44Fepat1FyuaPk2W3NcuTNZReuGZZS/QzsynVBoksE 0nrWMhG0D8HTuX1BDwQRKNPX5oYm8q628vdEdiWyQiABGy7D1qRPzEPlsJF8f9x68LX9 Cg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2wa9rq6gjr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:16 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iLCs090874 for ; Mon, 18 Nov 2019 08:47:16 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2watjx33qx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:16 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAI8lFLs010751 for ; Mon, 18 Nov 2019 08:47:15 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:15 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 06/15] btrfs: sysfs, move add remove _mounted function together Date: Mon, 18 Nov 2019 16:46:47 +0800 Message-Id: <20191118084656.3089-7-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The functions btrfs_sysfs_add_mounted() and btrfs_sysfs_remove_mounted() which add and remove files and directory under /sys/fs/btrfs/UUID keep them together to improve readability. No functional changes. Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 132 +++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 370f30561001..724af1322dce 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -742,21 +742,6 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add) return 0; } -void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) -{ - btrfs_reset_fs_info_ptr(fs_info); - - if (fs_info->space_info_kobj) { - sysfs_remove_files(fs_info->space_info_kobj, allocation_attrs); - kobject_del(fs_info->space_info_kobj); - kobject_put(fs_info->space_info_kobj); - } - addrm_unknown_feature_attrs(fs_info, false); - sysfs_remove_group(&fs_info->fs_devices->fsid_kobj, &btrfs_feature_attr_group); - sysfs_remove_files(&fs_info->fs_devices->fsid_kobj, btrfs_attrs); - btrfs_sysfs_remove_device_info(fs_info->fs_devices, NULL); -} - static const char * const btrfs_feature_set_names[FEAT_MAX] = { [FEAT_COMPAT] = "compat", [FEAT_COMPAT_RO] = "compat_ro", @@ -1028,6 +1013,72 @@ void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action) &disk_to_dev(bdev->bd_disk)->kobj); } +void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) +{ + btrfs_reset_fs_info_ptr(fs_info); + + if (fs_info->space_info_kobj) { + sysfs_remove_files(fs_info->space_info_kobj, allocation_attrs); + kobject_del(fs_info->space_info_kobj); + kobject_put(fs_info->space_info_kobj); + } + addrm_unknown_feature_attrs(fs_info, false); + sysfs_remove_group(&fs_info->fs_devices->fsid_kobj, &btrfs_feature_attr_group); + sysfs_remove_files(&fs_info->fs_devices->fsid_kobj, btrfs_attrs); + btrfs_sysfs_remove_device_info(fs_info->fs_devices, NULL); +} + +int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) +{ + int error; + struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; + struct kobject *fsid_kobj = &fs_devs->fsid_kobj; + + btrfs_set_fs_info_ptr(fs_info); + + error = btrfs_sysfs_add_device_info(fs_devs, NULL); + if (error) + return error; + + error = sysfs_create_files(fsid_kobj, btrfs_attrs); + if (error) { + btrfs_sysfs_remove_device_info(fs_devs, NULL); + return error; + } + + error = sysfs_create_group(fsid_kobj, + &btrfs_feature_attr_group); + if (error) + goto failure; + +#ifdef CONFIG_BTRFS_DEBUG + error = sysfs_create_group(fsid_kobj, + &btrfs_debug_feature_attr_group); + if (error) + goto failure; +#endif + + error = addrm_unknown_feature_attrs(fs_info, true); + if (error) + goto failure; + + fs_info->space_info_kobj = kobject_create_and_add("allocation", + fsid_kobj); + if (!fs_info->space_info_kobj) { + error = -ENOMEM; + goto failure; + } + + error = sysfs_create_files(fs_info->space_info_kobj, allocation_attrs); + if (error) + goto failure; + + return 0; +failure: + btrfs_sysfs_remove_mounted(fs_info); + return error; +} + void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices, const u8 *fsid) { @@ -1097,57 +1148,6 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs, return 0; } -int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) -{ - int error; - struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; - struct kobject *fsid_kobj = &fs_devs->fsid_kobj; - - btrfs_set_fs_info_ptr(fs_info); - - error = btrfs_sysfs_add_device_info(fs_devs, NULL); - if (error) - return error; - - error = sysfs_create_files(fsid_kobj, btrfs_attrs); - if (error) { - btrfs_sysfs_remove_device_info(fs_devs, NULL); - return error; - } - - error = sysfs_create_group(fsid_kobj, - &btrfs_feature_attr_group); - if (error) - goto failure; - -#ifdef CONFIG_BTRFS_DEBUG - error = sysfs_create_group(fsid_kobj, - &btrfs_debug_feature_attr_group); - if (error) - goto failure; -#endif - - error = addrm_unknown_feature_attrs(fs_info, true); - if (error) - goto failure; - - fs_info->space_info_kobj = kobject_create_and_add("allocation", - fsid_kobj); - if (!fs_info->space_info_kobj) { - error = -ENOMEM; - goto failure; - } - - error = sysfs_create_files(fs_info->space_info_kobj, allocation_attrs); - if (error) - goto failure; - - return 0; -failure: - btrfs_sysfs_remove_mounted(fs_info); - return error; -} - /* * Change per-fs features in /sys/fs/btrfs/UUID/features to match current From patchwork Mon Nov 18 08:46:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249137 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 870E614ED for ; Mon, 18 Nov 2019 08:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 66B6920740 for ; Mon, 18 Nov 2019 08:47:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ROHggtSk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726627AbfKRIrV (ORCPT ); Mon, 18 Nov 2019 03:47:21 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48184 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726614AbfKRIrU (ORCPT ); Mon, 18 Nov 2019 03:47:20 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iEpT105438 for ; Mon, 18 Nov 2019 08:47:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=yosvWSsN4KUauNOOigqSL5aQ0ReuLJMzzkiLsbi5IQg=; b=ROHggtSkdP5PqXorOM3/3P53MndyaN4iJ1GPAByrfSUbqCnpYcTA9eoXMlVWton3NCrS P1M93HEAFrJF1UagSp/t4jaDzUt6I25YJOYe5SNHLzeDbRFc3KTs3SFGrPVr0PmSKb4i ImvwC/eV90YjKKnuf49OVHdM9Q/SprQocomxDjq25G6RZnLZVCsLQpkohHwxzWalJyZo xUWkWefYuhTgZlK/yRBzLrvccRHTg0V86t7JmWP8i+ruMpU25afSwxOcSb/8s3tKuysf 8HK13zzsgIhipw3E4OgeG9dnv1c20uVXlSamDQfHOmtdahZ91GJdCcb8Naa6zUfnAVKj lw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2wa8htenr3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:19 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iKFP152757 for ; Mon, 18 Nov 2019 08:47:18 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2watmr3gu7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:18 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAI8lHd6010786 for ; Mon, 18 Nov 2019 08:47:17 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:17 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 07/15] btrfs: sysfs, delete code in a comment Date: Mon, 18 Nov 2019 16:46:48 +0800 Message-Id: <20191118084656.3089-8-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org commit 3ebb2ada (btrfs: sysfs: export supported checksums), added some unwanted commented-code, delete it. Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 724af1322dce..9494ccace624 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -255,16 +255,6 @@ BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID); BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE); BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34); -/* -static struct btrfs_feature_attr btrfs_attr_features_checksums_name = { - .kobj_attr = __INIT_KOBJ_ATTR(supported_checksums, S_IRUGO, - btrfs_supported_checksums_show, - NULL), - .feature_set = FEAT_INCOMPAT, - .feature_bit = 0, -}; -*/ - static struct attribute *btrfs_supported_feature_attrs[] = { BTRFS_FEAT_ATTR_PTR(mixed_backref), BTRFS_FEAT_ATTR_PTR(default_subvol), From patchwork Mon Nov 18 08:46:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 765BC14ED for ; Mon, 18 Nov 2019 08:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D31220748 for ; Mon, 18 Nov 2019 08:47:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="lXcS8G36" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726646AbfKRIrW (ORCPT ); Mon, 18 Nov 2019 03:47:22 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48206 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726464AbfKRIrW (ORCPT ); Mon, 18 Nov 2019 03:47:22 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i5qS105268 for ; Mon, 18 Nov 2019 08:47:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=4J2mgIEJeKlPDqBt/T75o0ODJ82ciFy8HNQX7DU/JB8=; b=lXcS8G36O61njP1J2x756JFAAkf1vqkstKgne/gEVWJ6ij/+bQKrJeAgKkwNBXX2h6Bj qh0BsXw2mtfeF17hLk6DkcIai1RgssGOuqQPjWghsmT1lB6BE9CLaegtpLe+PhrW+B2k e1wfhLwae7aJ7wVrKACpgQl0Bv1J0+A6uKtjJzMiVYa6xQV8k46uye40V9uIC9Ldvf61 n1N7PuR2RyjGC9FGhaBYIBxSMM12dZDPAEjjzH6cVWyEuOHrU0xmlfyZ03iHVywGtlrl 19QR1B+lV534U6xuS3S4+LSXDrgDLzDfTmRu3kQtkElsiXEZnh3Q1HZcKesyZy4EZKUS KA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2wa8htenr9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:20 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iJuV152713 for ; Mon, 18 Nov 2019 08:47:19 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2watmr3h2g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:19 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xAI8lJij018884 for ; Mon, 18 Nov 2019 08:47:19 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:18 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 08/15] btrfs: sysfs, btrfs_sysfs_add_fsid() drop unused argument parent Date: Mon, 18 Nov 2019 16:46:49 +0800 Message-Id: <20191118084656.3089-9-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Commit 24bd69cb (Btrfs: sysfs: add support to add parent for fsid) added parent argument in preparation to show the seed fsid under the sprout fsid as in the patch [1] in the mailing list. [1] Btrfs: sysfs: support seed devices in the sysfs layout But later this idea was superseded by another idea to rename the fsid as in the commit f93c39970b1d (btrfs: factor out sysfs code for updating sprout fsid). So we don't need parent argument anymore. Signed-off-by: Anand Jain --- fs/btrfs/disk-io.c | 2 +- fs/btrfs/sysfs.c | 11 +++++------ fs/btrfs/sysfs.h | 3 +-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 72191c213ac4..3f6a26d9afcd 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3082,7 +3082,7 @@ int __cold open_ctree(struct super_block *sb, btrfs_free_extra_devids(fs_devices, 1); - ret = btrfs_sysfs_add_fsid(fs_devices, NULL); + ret = btrfs_sysfs_add_fsid(fs_devices); if (ret) { btrfs_err(fs_info, "failed to init sysfs fsid interface: %d", ret); diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 9494ccace624..42aeb2375f2a 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1118,18 +1118,17 @@ void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs) } /* - * Can be called by the device discovery thread. - * And parent can be specified for seed device + * Creates: + * /sys/fs/btrfs/UUID */ -int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs, - struct kobject *parent) +int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs) { int error; init_completion(&fs_devs->kobj_unregister); fs_devs->fsid_kobj.kset = btrfs_kset; - error = kobject_init_and_add(&fs_devs->fsid_kobj, - &btrfs_ktype, parent, "%pU", fs_devs->fsid); + error = kobject_init_and_add(&fs_devs->fsid_kobj, &btrfs_ktype, NULL, + "%pU", fs_devs->fsid); if (error) { kobject_put(&fs_devs->fsid_kobj); return error; diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index 3dac8e163056..6addc35deb67 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h @@ -18,8 +18,7 @@ int btrfs_sysfs_add_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device); int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device); -int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs, - struct kobject *parent); +int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs); int btrfs_sysfs_add_devices_dir(struct btrfs_fs_devices *fs_devs); void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs); void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices, From patchwork Mon Nov 18 08:46:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249143 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FFE714DB for ; Mon, 18 Nov 2019 08:47:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F82720740 for ; Mon, 18 Nov 2019 08:47:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="MXf1xyf1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbfKRIrY (ORCPT ); Mon, 18 Nov 2019 03:47:24 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:47800 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726595AbfKRIrX (ORCPT ); Mon, 18 Nov 2019 03:47:23 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i3JW093462 for ; Mon, 18 Nov 2019 08:47:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=Fmbihwz7TwYMTRuvfY4VNpoGXhoK7kgf3v32UsZJroM=; b=MXf1xyf1komVCu9SBHQEoXAseSSErXOg3ltCgySR02EbMm4ep5APhzOux7N/8iM7Ge73 w8ZBEmiReX4lAmz5N3O36rzm3MSNZGJIA2fdCVvQOhQeGnjMj714D+2tyQ9tAi9CZrHK ZIMVlhCjJ2B+FBbBOpN50IXlgJoItpdnea5SPc5YC1BFPrmw1f4JOUuwB7cr5/FWcILq /beibXkGJS4FlnzBkfoilKp3zwzmMCQSUfpWzhMZTnjSDBt7nlqb4ifQjq70wj86XDWh Vx8TMppNcFtABne83ZuB1NSyykW3XLD07sCj1lLBu7pa+rIepZ5sPEGolfBrXt0C5Al5 mA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2wa92peka3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:21 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iL6Z152953 for ; Mon, 18 Nov 2019 08:47:21 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2watmr3hap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:21 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAI8lLxR005657 for ; Mon, 18 Nov 2019 08:47:21 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:20 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 09/15] btrfs: sysfs, merge btrfs_sysfs_add device_dir and fsid Date: Mon, 18 Nov 2019 16:46:50 +0800 Message-Id: <20191118084656.3089-10-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Merge btrfs_sysfs_add_fsid() and btrfs_sysfs_add_devices_dir() functions these two are small and they are called one after the other. Signed-off-by: Anand Jain --- fs/btrfs/disk-io.c | 7 ------- fs/btrfs/sysfs.c | 22 +++++++++------------- fs/btrfs/sysfs.h | 1 - 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 3f6a26d9afcd..ab888d89d844 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3089,13 +3089,6 @@ int __cold open_ctree(struct super_block *sb, goto fail_block_groups; } - ret = btrfs_sysfs_add_devices_dir(fs_devices); - if (ret) { - btrfs_err(fs_info, "failed to init sysfs device interface: %d", - ret); - goto fail_fsdev_sysfs; - } - ret = btrfs_sysfs_add_mounted(fs_info); if (ret) { btrfs_err(fs_info, "failed to init sysfs interface: %d", ret); diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 42aeb2375f2a..b42245104bc9 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -952,18 +952,6 @@ int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, return 0; } -int btrfs_sysfs_add_devices_dir(struct btrfs_fs_devices *fs_devs) -{ - if (!fs_devs->devices_dir_kobj) - fs_devs->devices_dir_kobj = kobject_create_and_add("devices", - &fs_devs->fsid_kobj); - - if (!fs_devs->devices_dir_kobj) - return -ENOMEM; - - return 0; -} - int btrfs_sysfs_add_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device) { @@ -1134,10 +1122,18 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs) return error; } + fs_devs->devices_dir_kobj = kobject_create_and_add("devices", + &fs_devs->fsid_kobj); + if (!fs_devs->devices_dir_kobj) { + btrfs_err(fs_devs->fs_info, + "failed to init sysfs device interface"); + kobject_put(&fs_devs->fsid_kobj); + return -ENOMEM; + } + return 0; } - /* * 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 diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index 6addc35deb67..e7ae91f68e36 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h @@ -19,7 +19,6 @@ int btrfs_sysfs_add_device_info(struct btrfs_fs_devices *fs_devices, int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device); int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs); -int btrfs_sysfs_add_devices_dir(struct btrfs_fs_devices *fs_devs); void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs); void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices, const u8 *fsid); From patchwork Mon Nov 18 08:46:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249141 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 978D914DB for ; Mon, 18 Nov 2019 08:47:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 775462075C for ; Mon, 18 Nov 2019 08:47:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="O7MZmSkx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbfKRIr0 (ORCPT ); Mon, 18 Nov 2019 03:47:26 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48298 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726712AbfKRIrZ (ORCPT ); Mon, 18 Nov 2019 03:47:25 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i8JT105412 for ; Mon, 18 Nov 2019 08:47:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=CC5pMmhR3fLlSBHBHMRSzLwSOcojt0hvET6EKsUN6a8=; b=O7MZmSkxyHH5FIB5HmgsVAFFL2KjqOm+Bi/bMJSyj4kOXM+H83CHw1ebp90ee1RKKOtl 6a+7LMDRYwYtM2p2b1E7NrqOSXK71kovD5t4vkzbWBNY1YvfGSaYgkb0nhBjUtbf2xHM iZLcM9T3bnDpXR9QtnITF7GI1W+uCGJ6bpzMBVEHcdf0kzq9XJqLhJzhPut/ieJob7Cg NCkFIi0UjfmukqEVrFXzCv6GECIWdvQ7FoUDP0N7ujE2/WMhZ0MQYg0L+5/4fXdQFPQY JelfCTqFGFEjihLVlWM4pk7LcRsVW68HbGOrfyjEwQ/RM9PGaM8zVq/KB+qJ+LkZmfAz /Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2wa8htenru-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:24 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iME5091066 for ; Mon, 18 Nov 2019 08:47:24 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2watjx33wq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:23 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xAI8lNKW018899 for ; Mon, 18 Nov 2019 08:47:23 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:22 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 10/15] btrfs: volume, btrfs_free_stale_devices() cleanup unreachable code Date: Mon, 18 Nov 2019 16:46:51 +0800 Message-Id: <20191118084656.3089-11-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org fs_devices::num_devices can be zero only in unmounted context, and we don't have any fsid specific kobjects in the unmoutend context. So no need to call btrfs_sysfs_remove_fsid() in btrfs_free_stale_devices(). Signed-off-by: Anand Jain --- We implemented this in preparation to provide the fsid/device attributes for the devices in unmoutned context as was proposed here [1]. [1] [PATCH] btrfs: Introduce device pool sysfs attributes fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 40d77b5846dc..fe135b5a8a03 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -585,7 +585,7 @@ static int btrfs_free_stale_devices(const char *path, mutex_unlock(&fs_devices->device_list_mutex); if (fs_devices->num_devices == 0) { - btrfs_sysfs_remove_fsid(fs_devices); + /* If its here fsid is unmounted */ list_del(&fs_devices->fs_list); free_fs_devices(fs_devices); } From patchwork Mon Nov 18 08:46:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249145 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E32751599 for ; Mon, 18 Nov 2019 08:47:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5B8E2075C for ; Mon, 18 Nov 2019 08:47:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="d+XYN33U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726747AbfKRIr3 (ORCPT ); Mon, 18 Nov 2019 03:47:29 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48350 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbfKRIr2 (ORCPT ); Mon, 18 Nov 2019 03:47:28 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i5Qn105350 for ; Mon, 18 Nov 2019 08:47:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=oyXnyz77rILHIZkDhbeyaLarc3ZrBapV9QTxpPLnIOY=; b=d+XYN33ULobIhsGK1uAjNKl8KfH9RLTiPa9pmrhC6iaZc33Ms3RjDSH7hV2t0gt6al3F 2Ilubxwi8DEQmGLKqdYyCj8JAIu+Hz0+ExaOFZaOxJ9PgIWBNkczm/c2fhTdY5tz7mXp ANtlfTKKcAdZrURNcnz0y+mS0kx7W7qZE0t+Q8vQOxvVK49YVFU4NkZkuhFKAUspqudy shJx6IV3aUNl6H3MjqfoGx5/8Vn6fjIln/ZI29fUQx7rnNt32xF6fSRf8gDWnzINZzyU nHbVFSwqaNyRFcEaqKo8CxyTdZAPFB/zaxL7+3GmHo1/htABdYXStmjdVOWpkQnzl9xO Pg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2wa8htens3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:26 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8hxaA021342 for ; Mon, 18 Nov 2019 08:47:25 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2wau8mtasw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:25 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAI8lP1q010851 for ; Mon, 18 Nov 2019 08:47:25 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:24 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 11/15] btrfs: sysfs, migrate fs_decvices::fsid_kobject to struct btrfs_fs_info Date: Mon, 18 Nov 2019 16:46:52 +0800 Message-Id: <20191118084656.3089-12-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In an idea that at some point we would have to create sysfs kobjects to show the scanned devices, so we tried to maintain the fsid_kobject in the struct btrfs_fs_devices instead of in the struct btrfs_fs_info. Its been without it for a long time and if it has to be done at some point it can be done using ioctl as well. For now cleanup sysfs and migrate the top most kobject in the mounted context to btrfs_fs_info. Signed-off-by: Anand Jain --- PS: There are patches in the ML [1], which shows scanned devices in the sysfs, if at all need there is a choice of doing the same using ioctl as well. So that we dont' have to stress already overloaded sysfs. [1] [PATCH] btrfs: Introduce device pool sysfs attributes fs/btrfs/ctree.h | 2 + fs/btrfs/disk-io.c | 8 ++-- fs/btrfs/sysfs.c | 94 ++++++++++++++++++++++------------------------ fs/btrfs/sysfs.h | 4 +- fs/btrfs/volumes.h | 3 +- 5 files changed, 54 insertions(+), 57 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index b2e8fd8a8e59..94446ed7a872 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -739,6 +739,8 @@ struct btrfs_fs_info { struct task_struct *cleaner_kthread; u32 thread_pool_size; + /* sysfs kobjects */ + struct kobject fsid_kobj; struct kobject *space_info_kobj; u64 total_pinned; diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index ab888d89d844..85ec0a3d2019 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3082,10 +3082,10 @@ int __cold open_ctree(struct super_block *sb, btrfs_free_extra_devids(fs_devices, 1); - ret = btrfs_sysfs_add_fsid(fs_devices); + ret = btrfs_sysfs_add_fsid(fs_info); if (ret) { btrfs_err(fs_info, "failed to init sysfs fsid interface: %d", - ret); + ret); goto fail_block_groups; } @@ -3308,7 +3308,7 @@ int __cold open_ctree(struct super_block *sb, btrfs_sysfs_remove_mounted(fs_info); fail_fsdev_sysfs: - btrfs_sysfs_remove_fsid(fs_info->fs_devices); + btrfs_sysfs_remove_fsid(fs_info); fail_block_groups: btrfs_put_block_group_cache(fs_info); @@ -4006,7 +4006,7 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info) percpu_counter_sum(&fs_info->dio_bytes)); btrfs_sysfs_remove_mounted(fs_info); - btrfs_sysfs_remove_fsid(fs_info->fs_devices); + btrfs_sysfs_remove_fsid(fs_info); btrfs_free_fs_roots(fs_info); diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index b42245104bc9..806676ef008a 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -62,7 +62,6 @@ static struct btrfs_feature_attr btrfs_attr_features_##_name = { \ BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature) static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj); -static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj); static struct btrfs_feature_attr *to_btrfs_feature_attr(struct kobj_attribute *a) { @@ -655,10 +654,10 @@ static const struct attribute *btrfs_attrs[] = { static void btrfs_release_fsid_kobj(struct kobject *kobj) { - struct btrfs_fs_devices *fs_devs = to_fs_devs(kobj); + struct btrfs_fs_info *fs_info = to_fs_info(kobj); - memset(&fs_devs->fsid_kobj, 0, sizeof(struct kobject)); - complete(&fs_devs->kobj_unregister); + memset(&fs_info->fsid_kobj, 0, sizeof(struct kobject)); + complete(&fs_info->fs_devices->kobj_unregister); } static struct kobj_type btrfs_ktype = { @@ -666,18 +665,11 @@ static struct kobj_type btrfs_ktype = { .release = btrfs_release_fsid_kobj, }; -static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj) -{ - if (kobj->ktype != &btrfs_ktype) - return NULL; - return container_of(kobj, struct btrfs_fs_devices, fsid_kobj); -} - static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj) { if (kobj->ktype != &btrfs_ktype) return NULL; - return to_fs_devs(kobj)->fs_info; + return container_of(kobj, struct btrfs_fs_info, fsid_kobj); } #define NUM_FEATURE_BITS 64 @@ -719,12 +711,12 @@ static int addrm_unknown_feature_attrs(struct btrfs_fs_info *fs_info, bool add) attrs[0] = &fa->kobj_attr.attr; if (add) { int ret; - ret = sysfs_merge_group(&fs_info->fs_devices->fsid_kobj, + ret = sysfs_merge_group(&fs_info->fsid_kobj, &agroup); if (ret) return ret; } else - sysfs_unmerge_group(&fs_info->fs_devices->fsid_kobj, + sysfs_unmerge_group(&fs_info->fsid_kobj, &agroup); } @@ -1001,8 +993,8 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) kobject_put(fs_info->space_info_kobj); } addrm_unknown_feature_attrs(fs_info, false); - sysfs_remove_group(&fs_info->fs_devices->fsid_kobj, &btrfs_feature_attr_group); - sysfs_remove_files(&fs_info->fs_devices->fsid_kobj, btrfs_attrs); + sysfs_remove_group(&fs_info->fsid_kobj, &btrfs_feature_attr_group); + sysfs_remove_files(&fs_info->fsid_kobj, btrfs_attrs); btrfs_sysfs_remove_device_info(fs_info->fs_devices, NULL); } @@ -1010,7 +1002,7 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) { int error; struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; - struct kobject *fsid_kobj = &fs_devs->fsid_kobj; + struct kobject *fsid_kobj = &fs_info->fsid_kobj; btrfs_set_fs_info_ptr(fs_info); @@ -1067,41 +1059,47 @@ void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices, * directory */ snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU", fsid); - if (kobject_rename(&fs_devices->fsid_kobj, fsid_buf)) + if (kobject_rename(&fs_devices->fs_info->fsid_kobj, fsid_buf)) btrfs_warn(fs_devices->fs_info, - "sysfs: failed to create fsid for sprout"); + "sysfs: failed to create fsid for sprout"); } /* /sys/fs/btrfs/ entry */ static struct kset *btrfs_kset; -static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs) +/* + * Remove /sys/fs/btrfs/UUID/devices and /sysfs/btrfs/UUID + */ +static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info) { - if (fs_devs->devices_dir_kobj) { - kobject_del(fs_devs->devices_dir_kobj); - kobject_put(fs_devs->devices_dir_kobj); - fs_devs->devices_dir_kobj = NULL; + struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; + + if (fs_devices->devices_dir_kobj) { + kobject_del(fs_devices->devices_dir_kobj); + kobject_put(fs_devices->devices_dir_kobj); + fs_devices->devices_dir_kobj = NULL; } - if (fs_devs->fsid_kobj.state_initialized) { - kobject_del(&fs_devs->fsid_kobj); - kobject_put(&fs_devs->fsid_kobj); - wait_for_completion(&fs_devs->kobj_unregister); + if (fs_info->fsid_kobj.state_initialized) { + kobject_del(&fs_info->fsid_kobj); + kobject_put(&fs_info->fsid_kobj); + wait_for_completion(&fs_devices->kobj_unregister); } } -/* when fs_devs is NULL it will remove all fsid kobject */ -void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs) +/* when fs_info is NULL it will remove all fs_info::fsid kobject */ +void btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info) { struct list_head *fs_uuids = btrfs_get_fs_uuids(); + struct btrfs_fs_devices *fs_devices; - if (fs_devs) { - __btrfs_sysfs_remove_fsid(fs_devs); + if (fs_info) { + __btrfs_sysfs_remove_fsid(fs_info); return; } - list_for_each_entry(fs_devs, fs_uuids, fs_list) { - __btrfs_sysfs_remove_fsid(fs_devs); + list_for_each_entry(fs_devices, fs_uuids, fs_list) { + __btrfs_sysfs_remove_fsid(fs_devices->fs_info); } } @@ -1109,25 +1107,25 @@ void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs) * Creates: * /sys/fs/btrfs/UUID */ -int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs) +int btrfs_sysfs_add_fsid(struct btrfs_fs_info *fs_info) { int error; + struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; - init_completion(&fs_devs->kobj_unregister); - fs_devs->fsid_kobj.kset = btrfs_kset; - error = kobject_init_and_add(&fs_devs->fsid_kobj, &btrfs_ktype, NULL, - "%pU", fs_devs->fsid); + init_completion(&fs_devices->kobj_unregister); + fs_info->fsid_kobj.kset = btrfs_kset; + error = kobject_init_and_add(&fs_info->fsid_kobj, &btrfs_ktype, NULL, + "%pU", fs_devices->fsid); if (error) { - kobject_put(&fs_devs->fsid_kobj); + kobject_put(&fs_info->fsid_kobj); return error; } - fs_devs->devices_dir_kobj = kobject_create_and_add("devices", - &fs_devs->fsid_kobj); - if (!fs_devs->devices_dir_kobj) { - btrfs_err(fs_devs->fs_info, - "failed to init sysfs device interface"); - kobject_put(&fs_devs->fsid_kobj); + fs_devices->devices_dir_kobj = kobject_create_and_add("devices", + &fs_info->fsid_kobj); + if (!fs_devices->devices_dir_kobj) { + btrfs_err(fs_info, "failed to init sysfs device interface"); + kobject_put(&fs_info->fsid_kobj); return -ENOMEM; } @@ -1141,7 +1139,6 @@ int btrfs_sysfs_add_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_fs_devices *fs_devs; struct kobject *fsid_kobj; u64 features; int ret; @@ -1152,8 +1149,7 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, features = get_features(fs_info, set); ASSERT(bit & supported_feature_masks[set]); - fs_devs = fs_info->fs_devices; - fsid_kobj = &fs_devs->fsid_kobj; + fsid_kobj = &fs_info->fsid_kobj; if (!fsid_kobj->state_initialized) return; diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index e7ae91f68e36..0648afbb40ca 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h @@ -18,8 +18,8 @@ int btrfs_sysfs_add_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device); int btrfs_sysfs_remove_device_info(struct btrfs_fs_devices *fs_devices, struct btrfs_device *one_device); -int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs); -void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs); +int btrfs_sysfs_add_fsid(struct btrfs_fs_info *fs_info); +void btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info); void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices, const u8 *fsid); void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 012e75f29fe0..3fd7f2b348b0 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -254,9 +254,8 @@ struct btrfs_fs_devices { struct btrfs_fs_info *fs_info; /* sysfs kobjects */ - struct kobject fsid_kobj; - struct kobject *devices_dir_kobj; struct completion kobj_unregister; + struct kobject *devices_dir_kobj; }; #define BTRFS_BIO_INLINE_CSUM_SIZE 64 From patchwork Mon Nov 18 08:46:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B35A14ED for ; Mon, 18 Nov 2019 08:47:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B0BB2075C for ; Mon, 18 Nov 2019 08:47:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="aO3p87qh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbfKRIra (ORCPT ); Mon, 18 Nov 2019 03:47:30 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48386 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbfKRIra (ORCPT ); Mon, 18 Nov 2019 03:47:30 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i50f105280 for ; Mon, 18 Nov 2019 08:47:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=fkE/WhsMJUadIyLQXTlpxnJg0tOtNrymqumRBL5m7Lo=; b=aO3p87qhr8Ojmt98H9cSPiyl2dMRM3pTzOL05uGwUGvU4Tppmye7ZG3ea4H3+WKwB6oG NmnyuACzcrNp8ELWV77pCd/tl8W7nnMt5jpX+oWUf13hzjiFks0ndpyUreE1IhNM5/7z TzJ/Z+YtI4JeOfJ1nGMbu2QdihgDnvictmuBc+pzB89p42FwrhOObLSiqSXqDMiI2amk Cxw5mxijQw5f/5zYc4RvRYrLZVcXDjwaNEeXx8svFTU5jcw+tdYFmztAh/CtxpY0KFfa quKX/6YNXFQvtpr9JtDXPcZh2JMslLVtKmUknTvHqYQEP0g/ORc240rC0VEE5rlbsIGT XA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2wa8htens7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:28 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iKVj152788 for ; Mon, 18 Nov 2019 08:47:27 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2watmr3j3n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:27 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAI8lRIf005690 for ; Mon, 18 Nov 2019 08:47:27 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:26 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 12/15] btrfs: sysfs, unexport btrfs_sysfs_add_mounted() Date: Mon, 18 Nov 2019 16:46:53 +0800 Message-Id: <20191118084656.3089-13-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org In open_ctree() we call btrfs_sysfs_add_fsid() to create /sys/fs/btrfs/UUID kobject, and in the following line of code in open_ctree() we call btrfs_sysfs_add_mounted() to create its attributes. And there is no other users of btrfs_sysfs_add_mounted(). So let btrfs_sysfs_add_fsid() also create its attributes and make btrfs_sysfs_add_mounted() a local static function. Signed-off-by: Anand Jain --- fs/btrfs/disk-io.c | 8 -------- fs/btrfs/sysfs.c | 9 ++++++++- fs/btrfs/sysfs.h | 1 - 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 85ec0a3d2019..8f6a08bef490 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3089,12 +3089,6 @@ int __cold open_ctree(struct super_block *sb, goto fail_block_groups; } - ret = btrfs_sysfs_add_mounted(fs_info); - if (ret) { - btrfs_err(fs_info, "failed to init sysfs interface: %d", ret); - goto fail_fsdev_sysfs; - } - ret = btrfs_init_space_info(fs_info); if (ret) { btrfs_err(fs_info, "failed to initialize space info: %d", ret); @@ -3306,8 +3300,6 @@ int __cold open_ctree(struct super_block *sb, fail_sysfs: btrfs_sysfs_remove_mounted(fs_info); - -fail_fsdev_sysfs: btrfs_sysfs_remove_fsid(fs_info); fail_block_groups: diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 806676ef008a..2ea27c2d9ef1 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -998,7 +998,7 @@ void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) btrfs_sysfs_remove_device_info(fs_info->fs_devices, NULL); } -int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) +static int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info) { int error; struct btrfs_fs_devices *fs_devs = fs_info->fs_devices; @@ -1129,6 +1129,13 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_info *fs_info) return -ENOMEM; } + error = btrfs_sysfs_add_mounted(fs_info); + if (error) { + btrfs_err(fs_info, "failed to init sysfs interface: %d", error); + btrfs_sysfs_remove_fsid(fs_info); + return error; + } + return 0; } diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index 0648afbb40ca..a977fe3bec64 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h @@ -28,7 +28,6 @@ void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action) int __init btrfs_init_sysfs(void); void __cold btrfs_exit_sysfs(void); -int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info); void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info); void btrfs_sysfs_add_block_group_type(struct btrfs_block_group *cache); int btrfs_sysfs_add_space_info_type(struct btrfs_fs_info *fs_info, From patchwork Mon Nov 18 08:46:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249151 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB51C14ED for ; Mon, 18 Nov 2019 08:47:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8ACC52075C for ; Mon, 18 Nov 2019 08:47:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="L84lV98F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbfKRIrd (ORCPT ); Mon, 18 Nov 2019 03:47:33 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:47930 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbfKRIrd (ORCPT ); Mon, 18 Nov 2019 03:47:33 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i4cW093613 for ; Mon, 18 Nov 2019 08:47:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=/nDjPX4hZwrKij0QTicl8iyGUL4yhoc8M2n3sDI8Zic=; b=L84lV98FECR9/1+RvX3LJr4CUUCa8ZXnHulXHSoLfC9OQtLhzDbNVtYg6BRj8fujFhT8 EDqcNf8Tvmm1u1FDjMPuMMoHxMeGruiTbjRi4nJwJzLhCPQkeZvU+RGChWOHAuoabNfn cj0hQt21P9loK8nW3qwd+dbGFOLhRS44GcfO6F5aOnvIXb82AV2VrOmQDRx/R9wb6IbY uvGtM5tEJQFobIvMXoQGnZCJjniVt5NL+Zn0+eRimTBFvFQwIqJHZ1NF3lwkwlqG4+xa TQeQvabgvTnPZ14bXQQTahEU44A5zJW7cGGTRQ3H8qA1JHDKCNNvAKKXFsSNYmVuVnGK MA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2wa92pekay-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:31 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8hvKT021063 for ; Mon, 18 Nov 2019 08:47:30 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2wau8mtaw7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:30 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xAI8lTO6003264 for ; Mon, 18 Nov 2019 08:47:30 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:28 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 13/15] btrfs: sysfs, cleanup btrfs_sysfs_remove_fsid() Date: Mon, 18 Nov 2019 16:46:54 +0800 Message-Id: <20191118084656.3089-14-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_sysfs_remove_fsid() when called with NULL argument then it shall cleanup all kobjects belonging to btrfs. However no function is using btrfs_sysfs_remove_fsid() with NULL argument. This happened in the commit 2e3e1281 (Btrfs: sysfs: provide framework to remove all fsid sysfs kobject) which is a helper commit to the proposed patch [1], which proposed to show /sys/fs/btrfs/UUID in the unmounted but scanned context as well, so that there is a way to know fsid and devices which are scanned. As of now there isn't anyway that the user/script can figure out all the scanned fsids/devices in the system, but its been long time, probably there isn't such a need at all. For developers to debug the struct fs_devices list there is procfs boiler-plate patch in the mailing list which comes handy. [1] [PATCH] btrfs: Introduce device pool sysfs attributes Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 2ea27c2d9ef1..34bf080ea530 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1087,20 +1087,9 @@ static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info) } } -/* when fs_info is NULL it will remove all fs_info::fsid kobject */ void btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info) { - struct list_head *fs_uuids = btrfs_get_fs_uuids(); - struct btrfs_fs_devices *fs_devices; - - if (fs_info) { - __btrfs_sysfs_remove_fsid(fs_info); - return; - } - - list_for_each_entry(fs_devices, fs_uuids, fs_list) { - __btrfs_sysfs_remove_fsid(fs_devices->fs_info); - } + __btrfs_sysfs_remove_fsid(fs_info); } /* From patchwork Mon Nov 18 08:46:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249149 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AB5A14DB for ; Mon, 18 Nov 2019 08:47:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A0E82075C for ; Mon, 18 Nov 2019 08:47:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="R39ldsz+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726775AbfKRIre (ORCPT ); Mon, 18 Nov 2019 03:47:34 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48450 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726717AbfKRIrd (ORCPT ); Mon, 18 Nov 2019 03:47:33 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iGUv105447 for ; Mon, 18 Nov 2019 08:47:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=lhGzhJpKFiMGH1TtdpqMX4b0d8tZVYlYleese42ssG0=; b=R39ldsz+u7dO45TgVTJTUiYE+pVe05ieP5On1u9kN9H8tX2lRkj575uEQaIUeIPFL9e/ 0Vkq000XvkzXC92EdyJHDjVlF1N7XKZhArf/GJZpkfn7EBT1ZfKbYlKScKA/4pcAgJOL p2tAylNPqZibE3FBN3Uy6C4kzEEY/j6M/NonkOmYQukpjGZC0LY8NnUP4OE0EYM5Z7eg JwfDMwEnUjg45j0q62GnGiTNpRhKgPiHZdMq3kuEGjxhCENdriV1cbdH6Ri/mImdOUjV ulWM9M++LnUKlWvft8MYhNtqK12aBPPD8Hmo6kcWv3YlGvqwZ5SwRkMN3irjn/WKGWAu dA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2wa8htenss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:32 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iLgU090883 for ; Mon, 18 Nov 2019 08:47:31 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2watjx343f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:31 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAI8lVO4010877 for ; Mon, 18 Nov 2019 08:47:31 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:30 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 14/15] btrfs: sysfs, merge btrfs_sysfs_remove_fsid() helper function Date: Mon, 18 Nov 2019 16:46:55 +0800 Message-Id: <20191118084656.3089-15-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Merge __btrfs_sysfs_remove_fsid() into its only caller btrfs_sysfs_remove_fsid(). Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 34bf080ea530..74210ef59641 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1070,7 +1070,7 @@ static struct kset *btrfs_kset; /* * Remove /sys/fs/btrfs/UUID/devices and /sysfs/btrfs/UUID */ -static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info) +void btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info) { struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; @@ -1087,11 +1087,6 @@ static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info) } } -void btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info) -{ - __btrfs_sysfs_remove_fsid(fs_info); -} - /* * Creates: * /sys/fs/btrfs/UUID From patchwork Mon Nov 18 08:46:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11249153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8424814DB for ; Mon, 18 Nov 2019 08:47:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 62B5320740 for ; Mon, 18 Nov 2019 08:47:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="D62WD+au" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbfKRIrg (ORCPT ); Mon, 18 Nov 2019 03:47:36 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:47970 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726717AbfKRIrf (ORCPT ); Mon, 18 Nov 2019 03:47:35 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8i5Cl093859 for ; Mon, 18 Nov 2019 08:47:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=UQ+wJBcUY5IVaVy8nUdJ5n8RGJ7HfaobKp4r43nnlAs=; b=D62WD+auVgabcdgNc9/ZOHhNoCVJ8gGLzXlxQ6KnaziGTIguwd/DPzfPk7/RZY2pi6Yq Era1qZBvXlogNxpHMAYbc5o7FBucLSUmV1jUjlCNhQOdq5wapMGMq2vj/Bn9aqnToioE DCCNnr1t4/51gDZDFcI6EvjNzyqoZR6250/afDKX+/Vpe4Bd55LGSt5b7p9fjeqmiFlO VdaX/xegK5J1Hteg3+hExi5qswdHrtsw4WjdDNibc5LRa48jlCzWonh3YZa1SqaSAig6 qiH7vvCXUBAzZiK39tIh3ckMENUCF9LFZrtrAhzpEZ9FH6FszDm6Y3Eq8DTJublAFQ1m kw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2wa92pekb6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:34 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAI8iL6e152953 for ; Mon, 18 Nov 2019 08:47:33 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2watmr3jw8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 18 Nov 2019 08:47:33 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xAI8lXMC019036 for ; Mon, 18 Nov 2019 08:47:33 GMT Received: from mb.wifi.oracle.com (/192.188.170.109) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 00:47:32 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 15/15] btrfs: sysfs, unexport btrfs_sysfs_remove_mounted() Date: Mon, 18 Nov 2019 16:46:56 +0800 Message-Id: <20191118084656.3089-16-anand.jain@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118084656.3089-1-anand.jain@oracle.com> References: <20191118084656.3089-1-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9444 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180079 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_sysfs_remove_mounted() is always called along with btrfs_sysfs_remove_fsid(), call btrfs_sysfs_remove_mounted() in btrfs_sysfs_remove_fsid() as well. And unexport btrfs_sysfs_remove_mounted(). Signed-off-by: Anand Jain --- fs/btrfs/disk-io.c | 2 -- fs/btrfs/sysfs.c | 4 +++- fs/btrfs/sysfs.h | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8f6a08bef490..28db7bbb437e 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3299,7 +3299,6 @@ int __cold open_ctree(struct super_block *sb, filemap_write_and_wait(fs_info->btree_inode->i_mapping); fail_sysfs: - btrfs_sysfs_remove_mounted(fs_info); btrfs_sysfs_remove_fsid(fs_info); fail_block_groups: @@ -3997,7 +3996,6 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info) btrfs_info(fs_info, "at unmount dio bytes count %lld", percpu_counter_sum(&fs_info->dio_bytes)); - btrfs_sysfs_remove_mounted(fs_info); btrfs_sysfs_remove_fsid(fs_info); btrfs_free_fs_roots(fs_info); diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 74210ef59641..468a42c442cf 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -983,7 +983,7 @@ void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action) &disk_to_dev(bdev->bd_disk)->kobj); } -void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) +static void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info) { btrfs_reset_fs_info_ptr(fs_info); @@ -1074,6 +1074,8 @@ void btrfs_sysfs_remove_fsid(struct btrfs_fs_info *fs_info) { struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; + btrfs_sysfs_remove_mounted(fs_info); + if (fs_devices->devices_dir_kobj) { kobject_del(fs_devices->devices_dir_kobj); kobject_put(fs_devices->devices_dir_kobj); diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index a977fe3bec64..2b01b3af5e50 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h @@ -28,7 +28,6 @@ void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action) int __init btrfs_init_sysfs(void); void __cold btrfs_exit_sysfs(void); -void btrfs_sysfs_remove_mounted(struct btrfs_fs_info *fs_info); void btrfs_sysfs_add_block_group_type(struct btrfs_block_group *cache); int btrfs_sysfs_add_space_info_type(struct btrfs_fs_info *fs_info, struct btrfs_space_info *space_info);