From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A8FAC71145 for ; Thu, 24 Aug 2023 21:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692911469; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3E/DjYBtrPQldjdJR84o32bb+mSTt1+YvBh2I5xGMcs=; b=hLdNtCa/IFoyVOcNOHIDKJHCPj4xWYuGEfSOLH+hbFW+Bwi3kCHso35bCW+xIAMX9bK/52 +2Qr5DFyqFBxQ9DnhxJOdy9rz3rdNpxCxNSLZhrEtEsThSeFKqrWOp9ix7ONxwBAecC7TI lbR86d8TwxfhRdPgkOXHUM3WB/rkL8I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-104-bCIhxXFjMMS-gg2eCYXBLw-1; Thu, 24 Aug 2023 17:11:06 -0400 X-MC-Unique: bCIhxXFjMMS-gg2eCYXBLw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A0FC3101A53C; Thu, 24 Aug 2023 21:11:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95677492C13; Thu, 24 Aug 2023 21:11:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6514619465B3; Thu, 24 Aug 2023 21:11:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 56D4E19465A3 for ; Thu, 24 Aug 2023 21:11:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 44E39492C18; Thu, 24 Aug 2023 21:11:04 +0000 (UTC) Received: from pasta.redhat.com (unknown [10.45.224.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA212492C3A; Thu, 24 Aug 2023 21:11:03 +0000 (UTC) From: Andreas Gruenbacher To: cluster-devel@redhat.com Date: Thu, 24 Aug 2023 23:10:59 +0200 Message-Id: <20230824211101.3242346-3-agruenba@redhat.com> In-Reply-To: <20230824211101.3242346-1-agruenba@redhat.com> References: <20230824211101.3242346-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Subject: [Cluster-devel] [PATCH 2/4] gfs2: low-memory forced flush fixes X-BeenThere: cluster-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: "\[Cluster devel\]" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: cluster-devel-bounces@redhat.com Sender: "Cluster-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Function gfs2_ail_flush_reqd checks the SDF_FORCE_AIL_FLUSH flag to determine if an AIL flush should be forced in low-memory situations. However, it also immediately clears the flag, and when called repeatedly as in function gfs2_logd, the flag will be lost. Fix that by pulling the SDF_FORCE_AIL_FLUSH flag check out of gfs2_ail_flush_reqd. In addition, in gfs2_writepages, logd needs to be woken up after setting the SDF_FORCE_AIL_FLUSH flag. Fixes: b066a4eebd4f ("gfs2: forcibly flush ail to relieve memory pressure") Signed-off-by: Andreas Gruenbacher --- fs/gfs2/aops.c | 4 +++- fs/gfs2/log.c | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 5f02542370c4..d15a10a18962 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -189,8 +189,10 @@ static int gfs2_writepages(struct address_space *mapping, * pages held in the ail that it can't find. */ ret = iomap_writepages(mapping, wbc, &wpc, &gfs2_writeback_ops); - if (ret == 0) + if (ret == 0) { set_bit(SDF_FORCE_AIL_FLUSH, &sdp->sd_flags); + wake_up(&sdp->sd_logd_waitq); + } return ret; } diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index d3da259820e3..aaca22f2aa2d 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -1282,9 +1282,6 @@ static inline int gfs2_ail_flush_reqd(struct gfs2_sbd *sdp) { unsigned int used_blocks = sdp->sd_jdesc->jd_blocks - atomic_read(&sdp->sd_log_blks_free); - if (test_and_clear_bit(SDF_FORCE_AIL_FLUSH, &sdp->sd_flags)) - return 1; - return used_blocks + atomic_read(&sdp->sd_log_blks_needed) >= atomic_read(&sdp->sd_log_thresh2); } @@ -1325,7 +1322,9 @@ int gfs2_logd(void *data) GFS2_LFC_LOGD_JFLUSH_REQD); } - if (gfs2_ail_flush_reqd(sdp)) { + if (test_bit(SDF_FORCE_AIL_FLUSH, &sdp->sd_flags) || + gfs2_ail_flush_reqd(sdp)) { + clear_bit(SDF_FORCE_AIL_FLUSH, &sdp->sd_flags); gfs2_ail1_start(sdp); gfs2_ail1_wait(sdp); gfs2_ail1_empty(sdp, 0); @@ -1338,6 +1337,7 @@ int gfs2_logd(void *data) try_to_freeze(); t = wait_event_interruptible_timeout(sdp->sd_logd_waitq, + test_bit(SDF_FORCE_AIL_FLUSH, &sdp->sd_flags) || gfs2_ail_flush_reqd(sdp) || gfs2_jrnl_flush_reqd(sdp) || kthread_should_stop(), -- 2.40.1