Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6633856iob; Wed, 11 May 2022 01:49:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsPvqqNCRdEKAOmYC1RDm2OPBfKf4D5GG451RMZjb+rDE2jFA1dWRRFdjamtIuSeZcvpbe X-Received: by 2002:a17:903:2045:b0:15e:fa7c:147f with SMTP id q5-20020a170903204500b0015efa7c147fmr18291997pla.105.1652258958036; Wed, 11 May 2022 01:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652258958; cv=none; d=google.com; s=arc-20160816; b=H+HV4kS6heHOnPmsWZvCjeyep9TLmD+p7lnWD+1vkB61EzuoY2H03FdBOuslSZzGqY mkmldBBfC9I6M5uVL53AKQtxKueuyizS/CdVZ+zMWxlHPYxdDE8jB75YQAdMUOtYkzmV 18KZ0Ah6VasVF92gRGlqFxNKUFPSU2o+7LzA8iW4Q2gxwyAoKNvemraJxQjA6lT5kYgJ E4ANfXEzgevvVIdbenoK2qPTqg/0YKzLDYXZO7yYY28SIQegCQ61+45uyycSDJmhtM8Q u0ITmJTy5HpGMVsWNirX/XyVCe+tT4yBPmPqP8hIAJ4X7RNFsyfX20ILm2S6Snm2kmaG 0yEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gzoa+jq0XpHGYJhcqgikWEC9JzeX9J0ZmovNXZZqPlw=; b=isCBuLfjmHEsvYu2T9YYtORb2LUYpb+n8vxUa8rRmpC7wzASK3KGYV0cDSakxCaIDD wyXuBaI4sLGkzb+NrjNJW1OTGhboS2cM9TOEdQO88UpzKuM2Sl+x9b8XeKoUt9rWXVrr lImZMAD3AQ7CmsgeEMpP2f0ivVxuV/IAwXuXWZFJ8y4W/B5ir9jzdu/OfKn527XBuhSN SFbn8LzXunLNA2dKJdoXTTv4P9pLrW0+KhrssQRHHzx+nu1TQHJnHhVtAQxwYg5CbM5p D/rsgcTlO8j9SfGufDEu9hLd6Kn8kXllS8stbCNAorFigl19KINUM3sajqg08kMAjO6n Ga0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pZSkpwiM; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m2-20020a17090a858200b001cbbd85faa9si5215519pjn.20.2022.05.11.01.48.55; Wed, 11 May 2022 01:49:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pZSkpwiM; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229579AbiEKHtD (ORCPT + 99 others); Wed, 11 May 2022 03:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243120AbiEKHtB (ORCPT ); Wed, 11 May 2022 03:49:01 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F74013B8C2; Wed, 11 May 2022 00:49:00 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id x52so1264162pfu.11; Wed, 11 May 2022 00:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gzoa+jq0XpHGYJhcqgikWEC9JzeX9J0ZmovNXZZqPlw=; b=pZSkpwiMq4LnqPxtv7NNZnd0sQ+5K2QkvF7M00OPRdBBKZbN6fzMaV6MJ4pqhUWVw3 qeiB5fkuIePt4fE3hDydIodwOhXdxl0yN1yC4BtaIbYFC+ePtdSDHCS+6VNb0eDtqYuk AulJ4HKphYw749hNPshP78whdF192rhBQAtAojzF8WIPZLHLj9KWjxaF+R4EuxjPyf9M RJsDZI6Vkw9VbFtfKnTlgLWfxzmwAMj4OmbM3iNnPFvEVQnCQE5AvAj4ZeRjchRJlPuz i/nCN41u69MS24J1UGFonJ092NoOkpxszFPNAY4W9uZsAuG1xoZ3tF7XAuaQJHbXsegC OVWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gzoa+jq0XpHGYJhcqgikWEC9JzeX9J0ZmovNXZZqPlw=; b=r4b24pAci37AEQA3b8U0NwpbeMeb03a1/1RrRcGl4HKOT9P0uvy4VATxsuz7184S89 1HuBX0ADYtM5nx3VdWeHQEwv8njW39oNF8XTeXb1FNr8JhWex/O7AlWa2gmsopUoIlSO uLjCLOjWYu+9QpAB5R6+49KRYmP4MLgtDd+vrgYqKofzsVb3/hsfKdbkTyk1xdt2SOrM Yn3JabPQffNSo7O3r8dYGaOQq91uoLu3Rp9e0ii3Msaap4/9LUD2c5AFY3LLqrXdCxZ0 F3MlogmGhm3aDqiamzKOnnmU5Hja50oQWqJhni44nrKjAn9/MIac2eLLNPupDt5g6OeV IKGQ== X-Gm-Message-State: AOAM531VrNHD9JxPYHw6jd/gJTma0+siEHicYvmini8YsEmNB8EHlIh7 XDJma0/nCWj7oBXoR4yIEjU= X-Received: by 2002:a63:6381:0:b0:3c6:4449:fc60 with SMTP id x123-20020a636381000000b003c64449fc60mr19232124pgb.457.1652255339674; Wed, 11 May 2022 00:48:59 -0700 (PDT) Received: from localhost ([2406:7400:63:532d:2759:da01:e9ea:1584]) by smtp.gmail.com with ESMTPSA id n19-20020a635913000000b003dafd8f0760sm1036339pgb.28.2022.05.11.00.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 00:48:59 -0700 (PDT) Date: Wed, 11 May 2022 13:18:53 +0530 From: Ritesh Harjani To: Ojaswin Mujoo Cc: linux-ext4@vger.kernel.org, Theodore Ts'o , Ritesh Harjani , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ext4: Fix journal_ioprio mount option handling Message-ID: <20220511074853.4xgdzagwmkp4ejuz@riteshh-domain> References: <20220418083545.45778-1-ojaswin@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220418083545.45778-1-ojaswin@linux.ibm.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 22/04/18 02:05PM, Ojaswin Mujoo wrote: > In __ext4_super() we always overwrote the user specified journal_ioprio > value with a default value, expecting parse_apply_sb_mount_options() to > later correctly set ctx->journal_ioprio to the user specified value. > However, if parse_apply_sb_mount_options() returned early because of > empty sbi->es_s->s_mount_opts, the correct journal_ioprio value was > never set. > > This patch fixes __ext4_super() to only use the default value if the ^^^ __ext4_fill_super > user has not specified any value for journal_ioprio. Also the problem is that ext4_parse_param() is called before __ext4_fill_super(). Hence when we overwrite ctx->journal_ioprio to default value in __ext4_fill_super(), that will end up ignoring the user passed journal_ioprio value via mount opts (which was passed earlier in ext4_parse_param()). > > Similarly, the remount behavior was to either use journal_ioprio > value specified during initial mount, or use the default value > irrespective of the journal_ioprio value specified during remount. > This patch modifies this to first check if a new value for ioprio > has been passed during remount and apply it. Incase, no new value is > passed, use the value specified during initial mount. Yup, here also ext4_parse_param() is called before __ext4_remount(). Hence we should check if the user has passed it's value in mount opts, if not, only then we should use the task original ioprio. I tested this patch and with the patch applied, the task ioprio can be correctly set using "journal_ioprio" mount option. "Mount test" ============= qemu-> sudo perf record -e probe:* -aR mount -o journal_ioprio=1 /dev/loop2 /mnt qemu-> ps -eaf |grep -E "jbd2|loop2" root 3506 2 0 07:41 ? 00:00:00 [jbd2/loop2-8] qemu-> sudo perf script mount 3504 [000] 2503.106871: probe:ext4_parse_param_L222: (ffffffff8147817f) journal_ioprio=16385 spec=32 mount 3504 [000] 2503.106908: probe:__ext4_fill_super_L26: (ffffffff8147a650) journal_ioprio=16385 spec=32 qemu-> ionice -p 3506 best-effort: prio 1 "remount test" ================= qemu-> sudo perf record -e probe:* -aR mount -o remount,journal_ioprio=0 /dev/loop2 /mnt qemu-> sudo perf script mount 3519 [000] 2544.958850: probe:ext4_parse_param_L222: (ffffffff8147817f) journal_ioprio=16384 spec=32 mount 3519 [000] 2544.958860: probe:__ext4_remount_L49: (ffffffff81479da2) journal_ioprio=16384 spec=32 qemu-> ionice -p 3506 best-effort: prio 0 "remount with no mount options" ================================= qemu-> sudo perf record -e probe:* -aR mount -o remount /dev/loop2 /mnt qemu-> ionice -p 3506 best-effort: prio 0 qemu-> sudo perf script mount 3530 [000] 2575.964048: probe:__ext4_remount_L49: (ffffffff81479da2) journal_ioprio=16384 spec=0 > > Signed-off-by: Ojaswin Mujoo We should add fixes tag too. Can you please confirm if that would be this patch? "ext4: Completely separate options parsing and sb setup". With that feel free to add below - Reviewed-by: Ritesh Harjani Tested-by: Ritesh Harjani -ritesh > --- > fs/ext4/super.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index c5a9ffbf7f4f..bfd767c51203 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -4427,7 +4427,8 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) > int silent = fc->sb_flags & SB_SILENT; > > /* Set defaults for the variables that will be set during parsing */ > - ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO; > + if (!(ctx->spec & EXT4_SPEC_JOURNAL_IOPRIO)) > + ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO; > > sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; > sbi->s_sectors_written_start = > @@ -6289,7 +6290,6 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb) > char *to_free[EXT4_MAXQUOTAS]; > #endif > > - ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO; > > /* Store the original options */ > old_sb_flags = sb->s_flags; > @@ -6315,9 +6315,14 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb) > } else > old_opts.s_qf_names[i] = NULL; > #endif > - if (sbi->s_journal && sbi->s_journal->j_task->io_context) > - ctx->journal_ioprio = > - sbi->s_journal->j_task->io_context->ioprio; > + if (!(ctx->spec & EXT4_SPEC_JOURNAL_IOPRIO)) { > + if (sbi->s_journal && sbi->s_journal->j_task->io_context) > + ctx->journal_ioprio = > + sbi->s_journal->j_task->io_context->ioprio; > + else > + ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO; > + > + } > > ext4_apply_options(fc, sb); > > -- > 2.27.0 >