Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3320810rwd; Mon, 29 May 2023 08:42:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5qcwEdGnxcwH2M2W+45+U2/QahCud8zbJJ2qvnlOWIcJxO8TyNepFn66aByqQFd5TM0Auc X-Received: by 2002:a05:6a00:1a0f:b0:64f:4706:3122 with SMTP id g15-20020a056a001a0f00b0064f47063122mr17700pfv.30.1685374971327; Mon, 29 May 2023 08:42:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685374971; cv=none; d=google.com; s=arc-20160816; b=fjqCK69uj1bmjcg8Mx116gjQE+rlTwPDcZe0Q00lqBXO0gHxZqB3ifywwBbPVGDwjd PY5z/1UD1T9eVQydpqtbMpLBuyfNenDETWEYo+a11hJ8HLN8JG1vm/BernWeeIDU1qDO Hj674YPkFJ1wZtH0je5tzGRy/RtnCn33M2q4Ec1ZuNMyq3tvvoGsDkUVQ2rvi8rzX+u7 Wkop4oHdeAXoem1o3scwWjRsPkMilv62y1XBoWZW6tt8w2GvYndSTD2FMfdii4GFGrUF 0UWxsWUDFtenLScT+/i2Z/gTcHFdps1CwtE3FtJFqgCmE1NywCZzFj0N4v0B8N1u7og6 8oOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=9LThTdNc3l0TTfcqKHMZIFh55bGZbjKiI/0a+5Ltvg0=; b=Tjs56m+PoucTkNKkC4lYtuIgY9TCV8BvEc9nD9wVepa/hJQVWohrhnezJCHd0JC1xe /dk7qEsReHlsXaFwi56lQxVfsDwy0jtP0yyA4lvMZYbvmzN9qXyVZQp5qmOo+BczhvVi LfuUK1453aiOxc01dQ0yIQmOEgypfEknZ9vq0v1iywmYgzf+Qhj/SBXtWUhOpqxKOGPu 4JEyC954AUFKdAEUC6pn47PN26l5iikzrnxfPMowBEZ/k6IKarbD46Y3Qzdh90IAFB9S uT4LQThRNY7gpW4x8VmZQ98U7g9Io/SObypc4uYfcwdY8YNdy/yRt88t3Wbmh+IF6Avg yW0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Kw3Hx4Cw; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z128-20020a626586000000b0063b8ab7f91csi81173pfb.365.2023.05.29.08.42.37; Mon, 29 May 2023 08:42:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@suse.de header.s=susede2_rsa header.b=Kw3Hx4Cw; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjE2P0x (ORCPT + 99 others); Mon, 29 May 2023 11:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229790AbjE2P0w (ORCPT ); Mon, 29 May 2023 11:26:52 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DACAC9 for ; Mon, 29 May 2023 08:26:48 -0700 (PDT) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C3E0321A87; Mon, 29 May 2023 15:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1685374006; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9LThTdNc3l0TTfcqKHMZIFh55bGZbjKiI/0a+5Ltvg0=; b=Kw3Hx4Cw+ZLE4wLRr0B8J/5bebN+MgZiyXz0l64lvJWZKfXbfET9SGYyeKxwuTRMW3jHMg w5aVMp3s85avm5mAvvfRkNJY7M3mIn8uOg8AQ6Fex031QYbhbl7eQh3HDlbxcWNX21XhcO VjpivPLoYAgB6qYPfMHP5iIjqrfF4Gc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1685374006; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9LThTdNc3l0TTfcqKHMZIFh55bGZbjKiI/0a+5Ltvg0=; b=B6ic1MO724bMQ4Ipm8jiEo4Uw9SO23DnqV1lKHbwVuf3A3nsbgK8pM/MfqY/xC1gZz2T2P 6KvrMhcXHeOSGgCQ== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 3CB31134BC; Mon, 29 May 2023 15:26:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id Abn3CjbEdGToAQAAGKfGzw (envelope-from ); Mon, 29 May 2023 15:26:46 +0000 Received: from localhost (brahms.olymp [local]) by brahms.olymp (OpenSMTPD) with ESMTPA id 757b2d04; Mon, 29 May 2023 15:26:45 +0000 (UTC) From: =?UTF-8?q?Lu=C3=ADs=20Henriques?= To: Mark Fasheh , Joel Becker , Joseph Qi , Heming Zhao Cc: ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org, =?UTF-8?q?Lu=C3=ADs=20Henriques?= Subject: [PATCH] ocfs2: check new file size on fallocate call Date: Mon, 29 May 2023 16:26:45 +0100 Message-Id: <20230529152645.32680-1-lhenriques@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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-kernel@vger.kernel.org When changing a file size with fallocate() the new size isn't being checked. In particular, the FSIZE ulimit isn't being checked, which makes fstest generic/228 fail. Simply adding a call to inode_newsize_ok() fixes this issue. Signed-off-by: Luís Henriques --- fs/ocfs2/file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index efb09de4343d..b173c36bcab3 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2100,14 +2100,20 @@ static long ocfs2_fallocate(struct file *file, int mode, loff_t offset, struct ocfs2_space_resv sr; int change_size = 1; int cmd = OCFS2_IOC_RESVSP64; + int ret = 0; if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) return -EOPNOTSUPP; if (!ocfs2_writes_unwritten_extents(osb)) return -EOPNOTSUPP; - if (mode & FALLOC_FL_KEEP_SIZE) + if (mode & FALLOC_FL_KEEP_SIZE) { change_size = 0; + } else { + ret = inode_newsize_ok(inode, offset + len); + if (ret) + return ret; + } if (mode & FALLOC_FL_PUNCH_HOLE) cmd = OCFS2_IOC_UNRESVSP64;