Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp928093rwb; Wed, 26 Jul 2023 05:17:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlElLJgtqUSrwKEIqpm7sFGq1Zh8ulo4/sHImaRYLwP8WWd3/p7e/AjeKnFTWSVBzQ9HnmWP X-Received: by 2002:a05:6402:4d5:b0:522:405e:dc1a with SMTP id n21-20020a05640204d500b00522405edc1amr1435466edw.41.1690373876376; Wed, 26 Jul 2023 05:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690373876; cv=none; d=google.com; s=arc-20160816; b=VvTDd8dt8b240VyBCl1/WVxmAJncljLUq9Yea2vl6nRn4qjIW856mh8VzR6d0KqgU5 6QhWm3R+eleD9p/9PK0WGhXfqsaSY6Kx1kfLivGv1jiwA9kTj3ipUrDq7DjIIarIRbzd pTPOAxc016QuwwatwieHrVDQqLZzZrNFH+CXt24KjqdR28/f/WW4/r/o6Z/hIzW3nX8b hMo9XHKiPChUR1SOTmsX9kuDJnDnmmXMKGVyRMsRlt+oduen+GMN6JtjZm6gdUACi+Mq gKu1WJiy2ZvgOt5BNeXgUob+TspbfmcngK/YwAooMVcu0Jw68vjMhxgZz5k6IwYuOzOS h6GA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Pom+EUyMYYQeMzw7Ruff4vSIuJsxO1g2AFt2EmqIW7g=; fh=s3EkFveja4PFWbIac+xkRWU8Dk/FoQIVbxjqrCu6kgU=; b=Pe7ppY3QYvP7T+7/xvvVrPGk6ffGwmR2S1rnkpTXTWKyH1+C2OualxvECH073puT++ JrW8b1yOcByzGu0rvishaGxMrOSuyr3oA4VDCURzlGIR/Pou+gEpZnN0mcr7YH4KUVLM xvdGUgHN/Jnup/WFSLm63hCdnPw6TCCriB4a+4yeTHqvCuTZ8XskKtQZVZe0Gq85Cuo3 FCreus0Ky4xv++/hQ5b970XHu8bDp2xrzAe6bVM0AMc3CU444mfz+xhiVCxAU3vTsPxN zDaifdSKDV3wdebVdpb2ZzquROenuxnWyM/ki7OG/9xb2be7AvIf64B+P8zO8wTLJ8a7 Ci8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fsU5snFl; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020aa7c306000000b0052257ffa20fsi1482061edq.454.2023.07.26.05.17.26; Wed, 26 Jul 2023 05:17:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@linux.dev header.s=key1 header.b=fsU5snFl; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233829AbjGZK1L (ORCPT + 99 others); Wed, 26 Jul 2023 06:27:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233812AbjGZK1A (ORCPT ); Wed, 26 Jul 2023 06:27:00 -0400 Received: from out-7.mta1.migadu.com (out-7.mta1.migadu.com [95.215.58.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B39F272B for ; Wed, 26 Jul 2023 03:26:48 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1690367205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pom+EUyMYYQeMzw7Ruff4vSIuJsxO1g2AFt2EmqIW7g=; b=fsU5snFl5wlkpiManVsyEaqkA3jtYtL56SiUXPkUd2iP9vfHwkwlJOE8O0ij0tynJqOi6S u2AAScVr21h+JW9OrGQSDOETHmX1xQd0ggkbmaQLOjwtEsyGae6SRkpvVpe6Em6ca2gLOa o2lPAr6Nf7qOVDfuuv28eZrhNR7FoQQ= From: Hao Xu To: io-uring@vger.kernel.org, Jens Axboe Cc: Dominique Martinet , Pavel Begunkov , Christian Brauner , Alexander Viro , Stefan Roesch , Clay Harris , Dave Chinner , "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, Wanpeng Li Subject: [PATCH 6/7] add vfs_lseek_nowait() Date: Wed, 26 Jul 2023 18:26:02 +0800 Message-Id: <20230726102603.155522-7-hao.xu@linux.dev> In-Reply-To: <20230726102603.155522-1-hao.xu@linux.dev> References: <20230726102603.155522-1-hao.xu@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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-ext4@vger.kernel.org From: Hao Xu Add a new vfs wrapper for io_uring lseek usage. The reason is the current vfs_lseek() calls llseek() but what we need is llseek_nowait(). Signed-off-by: Hao Xu --- fs/read_write.c | 18 ++++++++++++++++++ include/linux/fs.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index b07de77ef126..b4c3bcf706e2 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -290,6 +290,24 @@ loff_t vfs_llseek(struct file *file, loff_t offset, int whence) } EXPORT_SYMBOL(vfs_llseek); +loff_t vfs_lseek_nowait(struct file *file, off_t offset, + int whence, bool nowait) +{ + if (!(file->f_mode & FMODE_LSEEK)) + return -ESPIPE; + /* + * This function is only used by io_uring, thus + * returning -ENOTSUPP is not proper since doing + * nonblock lseek as the first try is asked internally + * by io_uring not by users. Return -ENOTSUPP to users + * is not sane. + */ + if (!file->f_op->llseek_nowait) + return -EAGAIN; + return file->f_op->llseek_nowait(file, offset, whence, nowait); +} +EXPORT_SYMBOL(vfs_lseek_nowait); + static off_t ksys_lseek(unsigned int fd, off_t offset, unsigned int whence) { off_t retval; diff --git a/include/linux/fs.h b/include/linux/fs.h index d37290da2d7e..cb804d1f1650 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2654,6 +2654,9 @@ extern loff_t default_llseek(struct file *file, loff_t offset, int whence); extern loff_t vfs_llseek(struct file *file, loff_t offset, int whence); +extern loff_t vfs_lseek_nowait(struct file *file, off_t offset, + int whence, bool nowait); + extern int inode_init_always(struct super_block *, struct inode *); extern void inode_init_once(struct inode *); extern void address_space_init_once(struct address_space *mapping); -- 2.25.1