Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4237190pxb; Tue, 26 Jan 2021 16:39:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgP61QDlOjBQb5BuIvi2anhUqZuPbpVCkcfadBT7FFipEi2xv7qk7uxbFTQEpUjEj0D4tz X-Received: by 2002:a05:6402:134b:: with SMTP id y11mr6512630edw.88.1611707951726; Tue, 26 Jan 2021 16:39:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611707951; cv=none; d=google.com; s=arc-20160816; b=XGF1nsWrizuXsU33PbRCBF/j57NGZRyfD/NnZtkvf2y5PeluDKhyNom7ocMngAPwVq iEFfVX09azeI4NoebL1w0ndHWnQL/GmKWKEXm5kwR6yp9AhkY36xFtCghhLH6Mz82lz6 VQiA/4N19kx4leWORGW0Vtizd8IrIFbZQY+PN58k4/RarpOAFGL6ARSz/enuafAVqlwb 0/gMC0hpOdj6yWGpS3riPAJH1taklYNtCBZZveI9LRCFtTke8HiIPDTB5WiBYGcJ/KAr Py3nPACa3yqqD0Z7JzqzVFMx7dsh1Dfh0MVz7KfmSetjPTayKv8nXH6x06r42uF4SV7E myLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9RUQDUCB4nEFZH/9cXs5GJzrckaItKmxCSraWMnirXk=; b=l22D+AAobHrdWCC00csla/XiQGJuOfs8Z8CeixH1mVDfcbpMCmkHwklLpyl5egXVZy qZTQ934kzKzMKrmo1YruaHhjF/8hqo9+mcP1+tMiChNhiKelmaAiJKw8KsG2aJvYrCXQ wE42JbAzj97Pqs9os5CQP9sn5U7kWb/i4ZOQ/zhZ/D93HRtSL+3TzFNbj6+R7Jp7p8+l XwTg82QAcGEpBPAygQAkc7Nkf6rN2GikkSwCTaRAKaevZiC3v0PPC9JcpYe2s0z+j3+o Owdfw8bLmCP4udJaNOJ34HHaP9DQWYFOn3gdc7OHQ1RSB8BmyPmNaCyPWHHgJE7qXY2R rOJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j3fMrSOE; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z27si62572edi.351.2021.01.26.16.38.47; Tue, 26 Jan 2021 16:39:11 -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=@gmail.com header.s=20161025 header.b=j3fMrSOE; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404321AbhA0A0G (ORCPT + 99 others); Tue, 26 Jan 2021 19:26:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389536AbhAZRPD (ORCPT ); Tue, 26 Jan 2021 12:15:03 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84DE7C06178A; Tue, 26 Jan 2021 09:14:32 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id jx18so2590226pjb.5; Tue, 26 Jan 2021 09:14:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9RUQDUCB4nEFZH/9cXs5GJzrckaItKmxCSraWMnirXk=; b=j3fMrSOEhbc64LKIGw9LoA5TX2A1MwYsnXX/wxqp5wCvR4f8+ezNT6wIaiEiNotTDF RlpLsvybHJnsnPtzk4FI/S974NL47u+bIjWabBSNRi2h7IoAZaoE92RRFZSqVEtaX6gx 7U1+MXIHKskmB7XhcFLRy1mw1XDXCDxzXKQRdagTRclfQQtFFwJMGYngT/umYZ3hqxNL 8rOXGMJ+3SeQ3PSZiXr1VV+cRbHqvAnuDtjM9Pbh12UE2RrfUlmBO1qxEq0DTJGovjaC t3cUkK9ZWenlRhQoi3gKdcWroQfpT5RLX79dquBmnGhgc6x8GxTyrefUipo8eSQfgkNE IQ/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9RUQDUCB4nEFZH/9cXs5GJzrckaItKmxCSraWMnirXk=; b=qqzf+Zn4HKqWUIEan4NJX+h2iB7veofJUsyPk4qt0brqOagMsup40emXKCX0/E5vtJ QeOpc0MzPF7455clEPObCCteLZQnOsD0b/cFylxpIWkqXFZMvVa+oGNOX0rGBRo2xCvG tGumwLRd6DnoxfeBAoHxYQLK43GSG7FBCCHkLmcNO7bQpmQjNjO/gqQr7kqRgSujYI1r QNipA3rW7ep8rpQluV7JK4NEsqUcfzS1AV3hfLpKVNGXapdigmT0iU87D9gDMnb1UCXg adg4LJVuESypOzqdaFtRvxq6HUIFtTSBTPP8WapPK/BIeRVZktaT7xVIN1k6vxOMK34c Z5jw== X-Gm-Message-State: AOAM533mS99g/x9hNyF8hkcY4cW2Ht9H6fwOWhXnLmgXqUHUeHGzaXA4 hFYAkNLqbpymlziiPgBaY7wwdcQqJarn5sW32zo= X-Received: by 2002:a17:90b:716:: with SMTP id s22mr763424pjz.223.1611681272019; Tue, 26 Jan 2021 09:14:32 -0800 (PST) MIME-Version: 1.0 References: <20201220065025.116516-1-goldstein.w.n@gmail.com> <0cdf2aac-6364-742d-debb-cfd58b4c6f2b@gmail.com> <20201222021043.GA139782@gmail.com> <32c9ce7e-569d-3f94-535e-00e072de772e@gmail.com> In-Reply-To: <32c9ce7e-569d-3f94-535e-00e072de772e@gmail.com> From: Noah Goldstein Date: Tue, 26 Jan 2021 12:14:21 -0500 Message-ID: Subject: Re: [PATCH] fs: io_uring.c: Add skip option for __io_sqe_files_update To: Pavel Begunkov Cc: noah , Jens Axboe , Alexander Viro , "open list:IO_URING" , "open list:FILESYSTEMS (VFS and infrastructure)" , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 26, 2021 at 7:29 AM Pavel Begunkov wrote: > > On 22/12/2020 02:10, Noah Goldstein wrote: > > On Sun, Dec 20, 2020 at 03:18:05PM +0000, Pavel Begunkov wrote: > >> On 20/12/2020 06:50, noah wrote:> From: noah > >>> > >>> This patch makes it so that specify a file descriptor value of -2 will > >>> skip updating the corresponding fixed file index. > >>> > >>> This will allow for users to reduce the number of syscalls necessary > >>> to update a sparse file range when using the fixed file option. > >> > >> Answering the github thread -- it's indeed a simple change, I had it the > >> same day you posted the issue. See below it's a bit cleaner. However, I > >> want to first review "io_uring: buffer registration enhancements", and > >> if it's good, for easier merging/etc I'd rather prefer to let it go > >> first (even if partially). > > Noah, want to give it a try? I've just sent a prep patch, with it you > can implement it cleaner with one continue. > Absolutely. Will get on it ASAP. > >> > >> diff --git a/fs/io_uring.c b/fs/io_uring.c > >> index 941fe9b64fd9..b3ae9d5da17e 100644 > >> --- a/fs/io_uring.c > >> +++ b/fs/io_uring.c > >> @@ -7847,9 +7847,8 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx, > >> if (IS_ERR(ref_node)) > >> return PTR_ERR(ref_node); > >> > >> - done = 0; > >> fds = u64_to_user_ptr(up->fds); > >> - while (nr_args) { > >> + for (done = 0; done < nr_args; done++) { > >> struct fixed_file_table *table; > >> unsigned index; > >> > >> @@ -7858,7 +7857,10 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx, > >> err = -EFAULT; > >> break; > >> } > >> - i = array_index_nospec(up->offset, ctx->nr_user_files); > >> + if (fd == IORING_REGISTER_FILES_SKIP) > >> + continue; > >> + > >> + i = array_index_nospec(up->offset + done, ctx->nr_user_files); > >> table = &ctx->file_data->table[i >> IORING_FILE_TABLE_SHIFT]; > >> index = i & IORING_FILE_TABLE_MASK; > >> if (table->files[index]) { > >> @@ -7896,9 +7898,6 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx, > >> break; > >> } > >> } > >> - nr_args--; > >> - done++; > >> - up->offset++; > >> } > >> > >> if (needs_switch) { > > -- > Pavel Begunkov