Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp619530pxx; Mon, 26 Oct 2020 17:07:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyCvvii47ZlpvDudqcxF8Qqy1c8unufVfNTK/5rtMUxA1ZijkgP8yapcYPX5qxU2oWuKLo X-Received: by 2002:aa7:dd8d:: with SMTP id g13mr5924061edv.87.1603757230898; Mon, 26 Oct 2020 17:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603757230; cv=none; d=google.com; s=arc-20160816; b=iyS9yhLgl9IZvMh4cZ995W55jMGtMw4eeeuw7oK7nplcMeXZfJfU9AdRG6ieJSJsM/ qqCKqbGSVsC0OyzEAo4TS0YlnkKVgUyL/mKSJMFYtnGxPJSgxOpmLpev2udfgR5GDQS8 YhUjOuwtG4fcPaNvt0/aFc3D+/UxbztXj3ll6R++FNlYL1m8m1m9F5mdzCK3WLvxpFsX sQbWq4r96l8l1/gqD4t+JhV7Cts95YU8m04s691N0XN65Mm9a5vMOe2fIp0jsj7wpsTs 0WkLFOlB+ZjXiwwXfTbKC+ZtmkLrpVPQYzs8p0akofN6kYfYuOR69Y42TzcPt0mDhplm QT3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Q5TvNsaVlP/v1waQo2fJokFjg82jq6VV+7J94XPAoyE=; b=KJUDKbl1oEpmdTCwyrmJ2E5BA6c0wPm09/SQ2vXz5Hf5Yvck2ClWfaFJN+zaPTXDCp T6qY8Q9KPY1lDniAfJUuBXyStjXXh62wL42yb04+wOt8272luOLG8BoRBE7VPKYHj0hR im8xVEcjwUM4imdhjgXlSFs6hUUAVn0PoFaZMlAfvBGwbaN8FgvQ2xRGnCL22d51/2dC b5zGAslD/QKJVuEGY/bbFX9GlW3HGQbW/hT5AnRIhG0qV1bJ5uzmmzXvtIGIFPvdNPRK 6Lj/Bl+lCfTfE9e2zstPqK3PIMBeUWZ0sgf0W1ikXgB0oRvV2Lc1iwWfPxN+eBCOcZZS RhBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WzDyNwYo; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c20si10238889ejr.515.2020.10.26.17.06.47; Mon, 26 Oct 2020 17:07:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WzDyNwYo; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 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 S2394422AbgJZW24 (ORCPT + 99 others); Mon, 26 Oct 2020 18:28:56 -0400 Received: from mail-ej1-f65.google.com ([209.85.218.65]:35119 "EHLO mail-ej1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394413AbgJZW24 (ORCPT ); Mon, 26 Oct 2020 18:28:56 -0400 Received: by mail-ej1-f65.google.com with SMTP id p5so16181908ejj.2; Mon, 26 Oct 2020 15:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q5TvNsaVlP/v1waQo2fJokFjg82jq6VV+7J94XPAoyE=; b=WzDyNwYol8TFmAY+cXVbW1Sx8M+rtCj2/MQaZtq/gX20miib2yDtzcZXIsXy5v2qDF ELoLTBMIsWlNg5Je+Xnk1nNEgb2x20eA1mQzDGmSbzojjfwOY0Zlldg1nfG25CvD4Zhz P4127mdv4gu29bClbLg5W51lnc1LJtoSLe06Xa4ettFQqEwuEKNw/NUhaAwpEYyl9Con dh5VRa9asNBlMtBwBBkPs2uOOD+Ch6uMwmL26I/PbPKpu9VeVfHs5kAkHZzGnhi9cge5 oHCFiSwBI/wk/R2WXNB/3DLaOYXQCV5OZCguyyqiwjZBSRBlpDYehZ/1w4JxhGUvFrdV wDPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q5TvNsaVlP/v1waQo2fJokFjg82jq6VV+7J94XPAoyE=; b=Xj4hG7CvrNAtwuDwi/Vp6VwzG4CjExqZg1ivSeX8e95QjlvYNONJzyosJBbfPkfd+2 jhETAPNYvqTeWLc4PS4FVu8PmEMW2QGGmTNYmsNcWN1yCjtUJx3IIKTdTRiTYhDMXnWe oEND4zMn9JLuP0ZGpz3f9EQI08A1qaYrvza/NVi6oHu2tBX0sWhvWnZpP6F7YnROsiWl /m2pF3fTInb4D9uu/qQtW0ekkKywx7SwWy99ACDabcKld90ZiobWgiVpHXp7LPAePeAr UNIAINScC3f521gScKDuOdoJVy6Z5N0i0znbIB1IDac9vYAVA1BufhGtAIRqYVX/06Rm B6CQ== X-Gm-Message-State: AOAM531pJWBxwKbRFM+WiD1vdzoVqsYyRcOUel6+2eDvrnBJFmV408xW Ut0JjBblfI7PnVTrbMSsFgcEFJr02Yic+WGeciytoUfKEEI= X-Received: by 2002:a17:906:640d:: with SMTP id d13mr17345666ejm.223.1603751332639; Mon, 26 Oct 2020 15:28:52 -0700 (PDT) MIME-Version: 1.0 References: <20201024140115.GA35973@xps-13-7390> In-Reply-To: <20201024140115.GA35973@xps-13-7390> From: harshad shirwadkar Date: Mon, 26 Oct 2020 15:28:41 -0700 Message-ID: Subject: Re: [PATCH] ext4: properly check for dirty state in ext4_inode_datasync_dirty() To: Andrea Righi Cc: "Theodore Ts'o" , Andreas Dilger , Ext4 Developers List , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Thanks Andrea for catching and sending out a fix for this. On Sat, Oct 24, 2020 at 7:01 AM Andrea Righi wrote: > > ext4_inode_datasync_dirty() needs to return 'true' if the inode is > dirty, 'false' otherwise, but the logic seems to be incorrectly changed > by commit aa75f4d3daae ("ext4: main fast-commit commit path"). > > This introduces a problem with swap files that are always failing to be > activated, showing this error in dmesg: > > [ 34.406479] swapon: file is not committed > > Simple test case to reproduce the problem: > > # fallocate -l 8G swapfile > # chmod 0600 swapfile > # mkswap swapfile > # swapon swapfile > > Fix the logic to return the proper state of the inode. > > Link: https://lore.kernel.org/lkml/20201024131333.GA32124@xps-13-7390 > Fixes: aa75f4d3daae ("ext4: main fast-commit commit path") > Signed-off-by: Andrea Righi > --- > fs/ext4/inode.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 03c2253005f0..a890a17ab7e1 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -3308,8 +3308,8 @@ static bool ext4_inode_datasync_dirty(struct inode *inode) > if (journal) { > if (jbd2_transaction_committed(journal, > EXT4_I(inode)->i_datasync_tid)) > - return true; > - return atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid) >= > + return false; > + return atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid) < > EXT4_I(inode)->i_fc_committed_subtid; In addition, the above condition should only be checked if fast commits are enabled. So, in effect this overall condition will look like this: if (journal) { if (jbd2_transaction_committed(journal, EXT4_I(inode)->i_datasync_tid)) return false; if (test_opt2(sb, JOURNAL_FAST_COMMIT)) return atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid) < EXT4_I(inode)->i_fc_committed_subtid; return true; } Thanks, Harshad > } > > -- > 2.27.0 >