Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7984866pxb; Fri, 19 Feb 2021 04:38:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyw7CNqiVppaKfsRB3V5CjHIHuClkDZmBR/WXIHtvVbW35ZlNlxH+kTtWuRunjFAEJfL9cB X-Received: by 2002:a17:906:1bf2:: with SMTP id t18mr8940742ejg.166.1613738301964; Fri, 19 Feb 2021 04:38:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613738301; cv=none; d=google.com; s=arc-20160816; b=F9FiFZgbfzxHGiYPmKzV0i/4N19iuzb7+dTUgl17kh/PO+M3zHpJmcZ5p9EOUB56G/ VKTHQdrv/GDsVGqTlSFXMCwBnJvQeUCIinZndvuSOCsl/SLkc8j7gQDf03HaS6Eha2JS bX2nDfFsk8Zot17yiZTwJ/rf0HxE5kCTaqPfhmx05QhveRpYqU3tPJrWfZfYV6nB+33T 9RT5oaCVJgklkSxMUgcwnGw6oMqK1lY0DD+J+kptWTtFVEL2WpucoTov6a0+yhJmmS+P n2mo31ezy3YJCulzrS4zKJAQaOaFTWWwKpk76EqgsdUVPP/xDeTn3lrsO/2jc0mC+gxa z8Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nL98NaEUG65NknpBy9GUqIWGRsbF73KZx2JYEgSxoFU=; b=qhOW0iwuTnkNTfQfIfCohVPhIWxH8f/4NbSbpvi7r9w3uQqsOdJPIqRAoClO24GhhZ 1qqBeIa1ditORjotsM3pp56Xewv98AEk+tCa06zEl3VtnfWDZjaq2uN0VvtaviVtuoPR CHTDLUmeWOS6u9T0f0r6fAwB4Ykvj4n6/i3upD9nAe5yzlKzShHkir0dw95xKdp+L9ek Q1ABRyQC2KZQ1QGVFb0q1NujN2VNM96e+1KGGfSvHuMHaCn7VPTH1zYfEI7BTQByeXKp ObTibaEjKHIu2G7udQNCitSGu+kJPIBk5MFf+sgOe84bEAjUhyMSpN1/0A8bFDFCF5bJ x3qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Q4YFIshm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si6190033edv.518.2021.02.19.04.37.56; Fri, 19 Feb 2021 04:38:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@infradead.org header.s=casper.20170209 header.b=Q4YFIshm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230305AbhBSMfj (ORCPT + 99 others); Fri, 19 Feb 2021 07:35:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230180AbhBSMfe (ORCPT ); Fri, 19 Feb 2021 07:35:34 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09694C061574; Fri, 19 Feb 2021 04:34:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=nL98NaEUG65NknpBy9GUqIWGRsbF73KZx2JYEgSxoFU=; b=Q4YFIshmnmtF49HHFoM/CY6k5w ymxpEqO/5tsL68tNH3SuI0KZVmjsvrGpYy8opVP5p7B3F2jhdRmcU5/FEbdGFT4tEzT2o+BnKqEVY cBwbAjXyUovorINQWgGJ1OuuML4889mhPJ1KfEjKvxhdniRRgUU8bTYWvcnyR1PP5zSzKjJygLHYK PQPQV+kT0/8onp9azO5bU7ZceuoN6rzJYfmawXNQB9pV4M0WOvDheZgPZfV4nIgitNxoawmVuLrgB VkNRc4kr6uIWGNZB2aKeXY+blRK/hgQnhAiMFFZIKK9HRbtYHwn71USfrXyVXxmO89Sa3kfOs/qps cvemhCHw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lD4yx-002rvc-31; Fri, 19 Feb 2021 12:34:17 +0000 Date: Fri, 19 Feb 2021 12:34:03 +0000 From: Matthew Wilcox To: Lennert Buytenhek Cc: Jens Axboe , Al Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, David Laight Subject: Re: [PATCH v3 2/2] io_uring: add support for IORING_OP_GETDENTS Message-ID: <20210219123403.GT2858050@casper.infradead.org> References: <20210218122640.GA334506@wantstofly.org> <20210218122755.GC334506@wantstofly.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210218122755.GC334506@wantstofly.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 18, 2021 at 02:27:55PM +0200, Lennert Buytenhek wrote: > IORING_OP_GETDENTS may or may not update the specified directory's > file offset, and the file offset should not be relied upon having > any particular value during or after an IORING_OP_GETDENTS call. This doesn't give me the warm fuzzies. What I might suggest is either passing a parameter to iterate_dir() or breaking out an iterate_dir_nofpos() to make IORING_OP_GETDENTS more of a READV operation. ie the equivalent of this: @@ -37,7 +37,7 @@ } while (0) -int iterate_dir(struct file *file, struct dir_context *ctx) +int iterate_dir(struct file *file, struct dir_context *ctx, bool use_fpos) { struct inode *inode = file_inode(file); bool shared = false; @@ -60,12 +60,14 @@ int iterate_dir(struct file *file, struct dir_context *ctx) res = -ENOENT; if (!IS_DEADDIR(inode)) { - ctx->pos = file->f_pos; + if (use_fpos) + ctx->pos = file->f_pos; if (shared) res = file->f_op->iterate_shared(file, ctx); else res = file->f_op->iterate(file, ctx); - file->f_pos = ctx->pos; + if (use_fpos) + file->f_pos = ctx->pos; fsnotify_access(file); file_accessed(file); } That way there's no need to play with llseek or take a mutex on the f_pos of the directory.