From patchwork Wed May 4 16:46:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 569664 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABBF4C433EF for ; Wed, 4 May 2022 17:14:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354921AbiEDRRj (ORCPT ); Wed, 4 May 2022 13:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356388AbiEDRNl (ORCPT ); Wed, 4 May 2022 13:13:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 713E94BFF4; Wed, 4 May 2022 09:57:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1585DB827B4; Wed, 4 May 2022 16:57:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B55A1C385A4; Wed, 4 May 2022 16:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683474; bh=WdSUIlFNvb+1GIbWLYslyQTqfXLiP1KfZajIkU8Io1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=no9+2HVZiywN2cBBHTX4mP3GOVNhrVD+W9tFNRyNkwkC9Ck0+SeY62X2IGKBKGclu a2NNZ5X8Q/IE1O1jdzmyXfHd0iNpGcgzYpXIOKLiWFqIousta6otWpz3uCeelNxW26 rQUJQB0m/6A5p6mVQcevoULhqEr+VWuppXtM7HFU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Gruenbacher , Sasha Levin Subject: [PATCH 5.17 149/225] gfs2: Make sure not to return short direct writes Date: Wed, 4 May 2022 18:46:27 +0200 Message-Id: <20220504153123.413413896@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153110.096069935@linuxfoundation.org> References: <20220504153110.096069935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Andreas Gruenbacher [ Upstream commit 3bde4c48586074202044456285a97ccdf9048988 ] When direct writes fail with -ENOTBLK because we're writing into a hole (gfs2_iomap_begin()) or because of a page invalidation failure (iomap_dio_rw()), we're falling back to buffered writes. In that case, when we lose the inode glock in gfs2_file_buffered_write(), we want to re-acquire it instead of returning a short write. Signed-off-by: Andreas Gruenbacher Signed-off-by: Sasha Levin --- fs/gfs2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index de0122806fb3..fdc7eda0437a 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -1069,7 +1069,7 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb, from->count = min(from->count, window_size - leftover); if (gfs2_holder_queued(gh)) goto retry_under_glock; - if (read) + if (read && !(iocb->ki_flags & IOCB_DIRECT)) goto out_uninit; goto retry; }