Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1730372pxb; Fri, 29 Jan 2021 03:56:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrhyA61MuUNrVqnvJHGCnC9LTnVOWtFQnsXnf51pkihCs6m6p5ClkQaNeekIMKsAlsn9vE X-Received: by 2002:a17:906:fc4:: with SMTP id c4mr4268417ejk.143.1611921384410; Fri, 29 Jan 2021 03:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611921384; cv=none; d=google.com; s=arc-20160816; b=Hdn+oCKNiBUiyhg2c26NrxytQtwLh4Lz22RqxQamLDf9ZQFOZCTjg/NMfazsIQG80y ieO7Ydh+PKzA/8Hc9jfimL00uO5ceijGKE0nJVcaCBpbiKig8D1zKtMYt5nXtPvPDuex mcvA0StOal0LvUQ2FYGxBmfat3+12gsrDnld3B1X3Vjv7KT4wbfCvOJ090zxBLpH0CuZ zs9Mj85i3pRoPKb7yUVBjJrfl0u7zr92iUtv/Cbj6AQRsIZBY9pEzblG1wuuVMeLU86B oFZmbvvAXLGAwxUg49/GT1YKlgTxFnhRmiUHDWDI7MHfukumjatx4d5NkAzAx9tr3+Yt 5LOQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IsGjd2GLvMqFhsLWvC6wwaxk3oY2v4EnuQfwN41Q618=; b=ELNZgaO8mPjHJDWm7ae/1yKKTd2GfguYApGpm9beke9Es4s2SWUZmpUFHxgcPMWUqb W6VniLbfj8sZrw9rYpuX3bKT5G7r72G0PS2ctnhB/s5bd2EqzqaKIXQ52uHdwp0g7079 UgqN9AsAPk8tbTnZHpIbfsffu2KanVGvTygCATqMRJRNw4SJGyHQ3hIy9FtGf7yDjA17 Twoi4i8ywO1DHqJVD2wO/blM+NTCkNckVJSpG6QkO+PcaiR2cqtmmWt9Mt0gdytQC0p9 s/Sm4hJf4Y1tYBeH31foiBzugyLThd1DkZ09acZKzZVot3v0O6Q1pSEj7Y6dzGaMVEU1 aFvg== 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 o16si4488105ejr.715.2021.01.29.03.55.59; Fri, 29 Jan 2021 03:56:24 -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 S232927AbhA2LxP (ORCPT + 99 others); Fri, 29 Jan 2021 06:53:15 -0500 Received: from hmm.wantstofly.org ([213.239.204.108]:51438 "EHLO mail.wantstofly.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232273AbhA2K0S (ORCPT ); Fri, 29 Jan 2021 05:26:18 -0500 Received: by mail.wantstofly.org (Postfix, from userid 1000) id 90D707F45D; Fri, 29 Jan 2021 12:20:57 +0200 (EET) Date: Fri, 29 Jan 2021 12:20:57 +0200 From: Lennert Buytenhek To: David Laight , Al Viro Cc: Jens Axboe , linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [RFC PATCH] io_uring: add support for IORING_OP_GETDENTS64 Message-ID: <20210129102057.GD193464@wantstofly.org> References: <20210123114152.GA120281@wantstofly.org> <20210128230710.GA190469@wantstofly.org> <20210129053703.GB190469@wantstofly.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210129053703.GB190469@wantstofly.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 29, 2021 at 07:37:03AM +0200, Lennert Buytenhek wrote: > > > > One open question is whether IORING_OP_GETDENTS64 should be more like > > > > pread(2)?and allow passing in a starting offset to read from the > > > > directory from. (This would require some more surgery in fs/readdir.c.) > > > > > > Since directories are seekable this ought to work. > > > Modulo horrid issues with 32bit file offsets. > > > > The incremental patch below does this. (It doesn't apply cleanly on > > top of v1 of the IORING_OP_GETDENTS patch as I have other changes in > > my tree -- I'm including it just to illustrate the changes that would > > make this work.) > > > > This change seems to work, and makes IORING_OP_GETDENTS take an > > explicitly specified directory offset (instead of using the file's > > ->f_pos), making it more like pread(2) [...] > > ...but the fact that this patch avoids taking file->f_pos_lock (as this > proposed version of IORING_OP_GETDENTS avoids using file->f_pos) means > that ->iterate_shared() can then be called concurrently on the same > struct file, which breaks the mutual exclusion guarantees provided here. > > If possible, I'd like to keep the ability to explicitly pass in a > directory offset to start reading from into IORING_OP_GETDENTS, so > perhaps we can simply satisfy the mutual exclusion requirement by > taking ->f_pos_lock by hand -- but then I do need to check that it's OK > for ->iterate{,_shared}() to be called successively with discontinuous > offsets without ->llseek() being called in between. > > (If that's not OK, then we can either have IORING_OP_GETDENTS just > always start reading at ->f_pos like before (which might then require > adding a IORING_OP_GETDENTS2 at some point in the future if we'll > ever want to change that), or we could have IORING_OP_GETDENTS itself > call ->llseek() for now whenever necessary.) Having IORING_OP_GETDENTS seek to sqe->off if needed seems easy enough to implement, and it simplifies the other code as well, so I'll send out a v2 RFC shortly that does this.