From patchwork Fri Mar 31 20:08:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Borowski X-Patchwork-Id: 9657265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 49E70601D2 for ; Fri, 31 Mar 2017 20:08:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FF35282EC for ; Fri, 31 Mar 2017 20:08:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F81C286F9; Fri, 31 Mar 2017 20:08:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14347282EC for ; Fri, 31 Mar 2017 20:08:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755159AbdCaUId (ORCPT ); Fri, 31 Mar 2017 16:08:33 -0400 Received: from tartarus.angband.pl ([89.206.35.136]:48182 "EHLO tartarus.angband.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754898AbdCaUIc (ORCPT ); Fri, 31 Mar 2017 16:08:32 -0400 Received: from umbar.angband.pl ([2001:6a0:118::6]) by tartarus.angband.pl with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.88) (envelope-from ) id 1cu2qN-0007JM-44; Fri, 31 Mar 2017 22:08:27 +0200 Received: from kilobyte by umbar.angband.pl with local (Exim 4.89) (envelope-from ) id 1cu2qq-0001sz-I2; Fri, 31 Mar 2017 22:08:52 +0200 From: Adam Borowski To: David Sterba , Hans van Kranenburg , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org Cc: Adam Borowski Date: Fri, 31 Mar 2017 22:08:50 +0200 Message-Id: <20170331200850.7067-1-kilobyte@angband.pl> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170331171016.GN4781@twin.jikos.cz> References: <20170331171016.GN4781@twin.jikos.cz> X-SA-Exim-Connect-IP: 2001:6a0:118::6 X-SA-Exim-Mail-From: kilobyte@angband.pl Subject: [PATCH v2] btrfs: drop the nossd flag when remounting with -o ssd X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on tartarus.angband.pl) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP And when turning on nossd, drop ssd_spread. Reported-by: Hans van Kranenburg Signed-off-by: Adam Borowski --- On Fri, Mar 31, 2017 at 07:10:16PM +0200, David Sterba wrote: > On Fri, Mar 31, 2017 at 06:00:08PM +0200, Hans van Kranenburg wrote: > > On 03/31/2017 05:19 PM, Adam Borowski wrote: > > > Not sure if setting NOSSD should also disable SSD_SPREAD, there's currently > > > no way to disable that option once set. > > Missing inverse of ssd_spread is probably unintentional, as we once > added all complementary no* options, this one was forgotten. > > And yes, nossd should turn off ssd and ssd_spread, as ssd_spread without > ssd does not nothing anyway. Added that. > > How did you test this? > > > > This was also my first thought, but here's a weird thing: > > > > -# mount -o nossd /dev/sdx /mnt/btrfs/ > > > > BTRFS info (device sdx): not using ssd allocation scheme > > > > -# mount -o remount,ssd /mnt/btrfs/ > > > > BTRFS info (device sdx): use ssd allocation scheme > > > > -# mount -o remount,nossd /mnt/btrfs/ > > > > BTRFS info (device sdx): use ssd allocation scheme > > > > That means that the case Opt_nossd: is never reached when doing this? Seems to work for me: [/tmp]# mount -onoatime foo /mnt/vol1 [ 619.436745] BTRFS: device fsid 954fd6c3-b3ce-4355-b79a-60ece7a6a4e0 devid 1 transid 5 /dev/loop0 [ 619.438625] BTRFS info (device loop0): disk space caching is enabled [ 619.438627] BTRFS info (device loop0): has skinny extents [ 619.438629] BTRFS info (device loop0): flagging fs with big metadata feature [ 619.441989] BTRFS info (device loop0): creating UUID tree [/tmp]# mount -oremount,ssd /mnt/vol1 [ 629.755584] BTRFS info (device loop0): use ssd allocation scheme [ 629.755589] BTRFS info (device loop0): disk space caching is enabled [/tmp]# mount -oremount,nossd /mnt/vol1 [ 633.675867] BTRFS info (device loop0): not using ssd allocation scheme [ 633.675872] BTRFS info (device loop0): disk space caching is enabled > > The fact that nossd,ssd,ssd_spread are different options complicates the > > whole thing, compared to e.g. autodefrag, noautodefrag. > > I think the the ssd flags reflect the autodetection of ssd, unlike > autodefrag and others. The autodetection works for /dev/sd* and /dev/mmcblk*, but not for most other devices. Two examples: nbd to a piece of rotating rust says: [45697.575192] BTRFS info (device nbd0): detected SSD devices, enabling SSD mode loop on tmpfs (and in case it spills, all swap is on ssd): claims it's rotational > The ssd options says "enable the ssd mode", but it could be also > auto-detected if the non-rotational device is detected. > > nossd says, "do not do the autodetection, even if it's a non-rot > device, also disable all ssd modes". These two options are nice whenever the autodetection goes wrong. > So Adam's patch needs to be updated so NOSSD also disables SSD_SPREAD. M'kay, updated this patch. > Adding the 'nossd_spread' would be good to have, even if it might be > just a marginal usecase. Not sure if there's much point. In any case, that's a separate patch. Should I add one while we're here? Meow! fs/btrfs/super.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 06bd9b332e18..ac1ca22d0c34 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -549,16 +549,19 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options, case Opt_ssd: btrfs_set_and_info(info, SSD, "use ssd allocation scheme"); + btrfs_clear_opt(info->mount_opt, NOSSD); break; case Opt_ssd_spread: btrfs_set_and_info(info, SSD_SPREAD, "use spread ssd allocation scheme"); btrfs_set_opt(info->mount_opt, SSD); + btrfs_clear_opt(info->mount_opt, NOSSD); break; case Opt_nossd: btrfs_set_and_info(info, NOSSD, "not using ssd allocation scheme"); btrfs_clear_opt(info->mount_opt, SSD); + btrfs_clear_opt(info->mount_opt, SSD_SPREAD); break; case Opt_barrier: btrfs_clear_and_info(info, NOBARRIER,