Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp8216483pxb; Fri, 19 Feb 2021 10:10:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEotvVZaVo26b2LG+ksD3WOV/Q+CTmxre1m9J6RmFBcy6zkbWyhAGSM9IaVfS256ZwOMyl X-Received: by 2002:a17:906:2f07:: with SMTP id v7mr9743574eji.343.1613758228993; Fri, 19 Feb 2021 10:10:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613758228; cv=none; d=google.com; s=arc-20160816; b=sELYrf3WAH5z3pynHD8UdkcSQffQmUlmc9EEs7dnrkIwRJRZZUMz6Ei/GQWGRRh7/D Imp2iUQfx8pQVi9ODd4McbOFBoChByItfLJG+YT7BvpekY9lGk3haqTCe2U1+zOyxBSj rsgId5OjsItZ/uTl9DT1HYoSa/LVTqP/R+pZeouCyEfPafje+oRFo0dZKfxwBS+pUxOd mcbBsraJh7EMuAn3yTVWhuPOHs1zliY26sUcR35kTLQhzTRHdmi0ts45UHQn8rSLcYVi KwuhBJLIRCfbhvzTcATXr/HTXnZL5BghIm3GYZh1klS2Mhswq2SIJceMTZDyTx6vVJja CDbQ== 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; bh=nc0h1KFcbNt7D1g8lOStehqnsiL8qK4oMjrI0ewL/Fs=; b=yIULcsffbx86IR/Lyr4FmT2TTPc/buXHk4Jc3+hw6D9VBjzvwJmN4FAl0wvUtUHCWG T4vn6jf4cFxedQ4r5Uq5a+GVNIJ5dqRdrS0i4LzDrXNonA+9S2y3hS4qj8D3+RuSRDTf +18Z3N/X0KN8SRLDgma3JNYNB2DxtthMBjbYPkEAS91xNPDgy0uj9LibR4lNlarZwGWB Zyk+xxc8eMVLS+4jQixd61Ve8ElUKDyZ0iZ0heZrvDnkcjpWzLDUw2vPeFhavgaW+CVI Ovdsu5a7JkAJ+jbyCPHdj7Md4c9V2MjwM3h2ktPRdcVVTgfBC1CgY084wnTHj35JsWVy bHmQ== ARC-Authentication-Results: i=1; mx.google.com; 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 p24si1568760ejw.511.2021.02.19.10.10.04; Fri, 19 Feb 2021 10:10:28 -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; 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 S229844AbhBSSHt (ORCPT + 99 others); Fri, 19 Feb 2021 13:07:49 -0500 Received: from hmm.wantstofly.org ([213.239.204.108]:59320 "EHLO mail.wantstofly.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbhBSSHr (ORCPT ); Fri, 19 Feb 2021 13:07:47 -0500 Received: by mail.wantstofly.org (Postfix, from userid 1000) id 967BD7F4BD; Fri, 19 Feb 2021 20:07:04 +0200 (EET) Date: Fri, 19 Feb 2021 20:07:04 +0200 From: Lennert Buytenhek To: Matthew Wilcox 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: <20210219180704.GD342512@wantstofly.org> References: <20210218122640.GA334506@wantstofly.org> <20210218122755.GC334506@wantstofly.org> <20210219123403.GT2858050@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210219123403.GT2858050@casper.infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 19, 2021 at 12:34:03PM +0000, Matthew Wilcox 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. I'll try this!