Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp696039pxx; Wed, 28 Oct 2020 14:47:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGYDFxI+tF6Vy7jZzeZ/gB4AMoZOxofP6AN25Q+eskwN6Cz7u2l43a0TvqWD+O7Wi7wufS X-Received: by 2002:a50:cf45:: with SMTP id d5mr936843edk.225.1603921644975; Wed, 28 Oct 2020 14:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603921644; cv=none; d=google.com; s=arc-20160816; b=UqWmlFhrcDSf176tkN9sp/OnIUwmv3lTncXEzGaJMn9s6zJv39mPDx1F+/mo5PNEXP xM20QFenW425OFuSuvDTC9UIp6/8Yd4oRxaE25D0D0N21541x5KM/Vfk6VzTqz5fCuRd hc6KOaWdX8OuhTo9nSErJY/HHqp5/mP83fggX3rfYNx6nq7vUqaGAabpRdacCfA0+vJI FUnq0gGiiaW2zNhkbSTW4cPdFeyZCfUw+Oo+6jdNe1YiaizsgeybGAndLLooeYcG1mp6 wcsPlqLMvmha6Ny4uiJV/hG7hZJxfglR+k/AYaTuP/57KQB8f722S03A6NWI4wGxFWAp oUqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=RGq50YJra8Pb7fSvcsNloSoc07LWHTFNTt54VxHxUL8=; b=dxg1XKrS29fP6DRg6boFqHuT8qWyeyhs0zeIoE/XhLuIemfI4zBk0N0e9HbsiXR6Sp QjU9GqFxuUI2RFxgA7UUd5Bt0QXet00r7JKq34dmuHmP2AuAyyOZUB+dz7gJHg9fm9j2 nUPOo9UAiLFDmGNlO7Ml/VxZQjh18LMZy36M21X85BWwb+mrVIfkMsNNbYKrBOOXodAU Mg/arV4tGtUgvRKXGHAefSzoY5O0PDav5wXxIgGdr+orgG1lWcw/m9mqAjHWEM7WjJdA FI1peXoTIrqPZQB+KOXK4UO3rbmowtNLOE03g2w0+yQR1iCcr2wkuUmsKKIDVJL3kVhI JbYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Be9YRtFk; 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=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si398845ejd.276.2020.10.28.14.47.01; Wed, 28 Oct 2020 14:47:24 -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=@ibm.com header.s=pp1 header.b=Be9YRtFk; 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=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726060AbgJ1Vpe (ORCPT + 99 others); Wed, 28 Oct 2020 17:45:34 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55636 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726478AbgJ1Vny (ORCPT ); Wed, 28 Oct 2020 17:43:54 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09S331XB143515; Tue, 27 Oct 2020 23:27:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=RGq50YJra8Pb7fSvcsNloSoc07LWHTFNTt54VxHxUL8=; b=Be9YRtFkvCQdd6oINp8zRwRqyP4UkMearsBsw79J1iL782479TA5mafAq7ZwHqDCm2z7 Pozml2LsV4+759qe3ssIsK7vOGA04TVNdKrDkPqRFm/URQX5LVUlbxANWawQTtj3HkKz Hy4pZWUlOXei4ufK4DCoDBeAtAhUhASA/a7k1IMwrrWrQ0QNovNpW+QJpc8uWP9uyOwD 0A8FX2ScZTjYZ0/+4ccGlMh8Nrr+7rvHWFpPMREmtvbV231LMCrMzTZkDdLQF/KAZj1b 0fL09tH82lloHOYUlJw9c07lo36SGKjzvmuLVobiRh6bMhLyyh/M5MWqLSCisSVYnG97 yQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 34ec5uprfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2020 23:27:10 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 09S347X2146835; Tue, 27 Oct 2020 23:27:09 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 34ec5uprf9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2020 23:27:09 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09S3NI7Y014988; Wed, 28 Oct 2020 03:27:08 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03fra.de.ibm.com with ESMTP id 34cbw8232j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Oct 2020 03:27:07 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 09S3R5sl31981902 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Oct 2020 03:27:05 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8D73A4051; Wed, 28 Oct 2020 03:27:05 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49482A4055; Wed, 28 Oct 2020 03:27:04 +0000 (GMT) Received: from [9.199.33.247] (unknown [9.199.33.247]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 28 Oct 2020 03:27:04 +0000 (GMT) Subject: Re: [PATCH] ext4: properly check for dirty state in ext4_inode_datasync_dirty() To: harshad shirwadkar , Andrea Righi Cc: "Theodore Ts'o" , Andreas Dilger , Ext4 Developers List , linux-kernel@vger.kernel.org References: <20201024140115.GA35973@xps-13-7390> From: Ritesh Harjani Message-ID: Date: Wed, 28 Oct 2020 08:57:03 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-10-27_17:2020-10-26,2020-10-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 lowpriorityscore=0 adultscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 priorityscore=1501 spamscore=0 suspectscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010280014 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 10/27/20 3:58 AM, harshad shirwadkar wrote: > 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 >> Well, I too noticed this yesterday while I was testing xfstests -g swap. Those tests were returning _notrun, hence that could be the reason why it didn't get notice in XFSTESTing from Ted. - I did notice that this code was introduced in v10 only. This wasn't there in v9 though. >> 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; > } Yup - I too had made a similar patch. But then I also noticed that below condition will always remain false. Since we never update "i_fc_committed_subtid" other than at these 2 places (one during init where we set it to 0 and other during ext4_fc_commit() where we set it to sbi->s_fc_subtid). atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid < EXT4_I(inode)->i_fc_committed_subtid Maybe I need more reading around this. -ritesh > > Thanks, > Harshad > >> } >> >> -- >> 2.27.0 >>