Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp1807614rwe; Sat, 15 Apr 2023 06:25:35 -0700 (PDT) X-Google-Smtp-Source: AKy350Y9rju4p2YdTXHuvmQM+h+befuT6pjZJJegZvrBRG1jOlpdH6z+rEJ9byNXAYkTBMC5FZbM X-Received: by 2002:a05:6a00:179e:b0:63b:7b29:46d7 with SMTP id s30-20020a056a00179e00b0063b7b2946d7mr3133256pfg.13.1681565135657; Sat, 15 Apr 2023 06:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681565135; cv=none; d=google.com; s=arc-20160816; b=CnHLtJAEkj8Mr3V5yt4F0oPAENqXuTqaFlKVQTkhreZY4AGvTiD3ouah8ktW0NXbLK 3b1/W38Q9iYvnLT0FwmUX46ZqoZ7cOdYpQxwp7quav6eiqDrbX4BqKnW1NC3tw0Q3bnv 61s9uo9myzVSszAGJDD1sBNDNZX6slYiK3pdL54instzl6B5mJQoiBbUqOs/NqvrgfSw T0I1BSDNfVvaUxNOEiZN61VUS8JesNe7vxJ+FNsJei7I7NA2/Xm3Z+tyIWD4Gn7jHq74 R9zspa0qiFSKAwuk0UPEOERStu6hxmqCB8awyJwfOJ2Fjp/PO6e4/hNjezkw4yiE0Aow cu/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=FDoeyOkk6TLcbWPLicxk2nAcFd4vulVwN1Th/ORcIBE=; b=MdeuULsOZU/PPsYC/KTQc2XuDTdVkhizYWyfgkWw2T5Ndn4j/XmdGWwz71lacvfxTf VaPH63zeuoJ/NRQ4LMpXxxL6iLfqyj1hx9BR7VU4ri2FOniZFxTr0nxW3cOkZkYIhvt7 mnsSvogKoaNRpNS3NgtzvsGS7xY5l5QzExA687xu4qLrHRU01OGJsglE9qEf5MQSItcs AjSnA8PUjv0FCR88A6zsg3sSTgQc6Ny7/ww6uO/z3Iucub+9J0iJS3kOBV4FtWBuSCxq IH0hZ3XGRzviAH5+cmCG9vT7gC+W/5jCXcItgwyc/e/r/Nan5YGn+nClX7ncxVAEX9o7 YS/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=Ozs96uUd; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 144-20020a621896000000b00633d39d7b09si6673529pfy.390.2023.04.15.06.25.17; Sat, 15 Apr 2023 06:25:35 -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=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=Ozs96uUd; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbjDONPz (ORCPT + 99 others); Sat, 15 Apr 2023 09:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbjDONPy (ORCPT ); Sat, 15 Apr 2023 09:15:54 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B036E4C32 for ; Sat, 15 Apr 2023 06:15:52 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-63b5312bd34so441557b3a.0 for ; Sat, 15 Apr 2023 06:15:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20221208.gappssmtp.com; s=20221208; t=1681564552; x=1684156552; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=FDoeyOkk6TLcbWPLicxk2nAcFd4vulVwN1Th/ORcIBE=; b=Ozs96uUdlsV0iLwm5FkjhtfWxZXFvC4NsM6s3QV+/Uck/NrbDym76dousQcXck9W/Z nPM0AOkUDstn5Y0BEiBbeZBzxlpCk6tnVCTUhZwYfHs7ZjXv1m1Yxg3nYguITdjZPm7L HOKKUc06HE5z9DMxRN44fOtuAb2lvQwCtpmOI3aLIwjxlCnMGDewtG28ZOqJ91KjzQ9N knF+H2RjY8Mf4eIymjkzgf5jLvlLVPqwer9pyGaYB0vuX8MIH9KMkJO12mDetxNZuXjk qIrW3nveZIEtE6Up0JdLcmsSzN1KRANcURzkTRy0cEZ9bVO+6Jn6tfrb495kenJud+7Z +zTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681564552; x=1684156552; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FDoeyOkk6TLcbWPLicxk2nAcFd4vulVwN1Th/ORcIBE=; b=We44LwFCJBeDMfznpYxWAohKlLl622pnnh9MUtJX7xxReArPfQqthml8x8AHna4MUB cRYExbMm27VcCMewPF7SOGOPBhfj0rV1IU9ZVGOfcmjKPM+IF0PE3uRHsTZwrJd9LDSC oD08rFLxcq8ZEt0yADZTMWK3YgqmWgcVensNSwFaPmD1yTvgJbku9ryzA/RtEfWjWuVA CBtpgzE4cNuFaZay66rdpDCLSag0HPmiML6w+Y9CTLkyw221xKVHGcK2PSwnOKYfs9CL kbztQvjPc8W2/H3U/mC+NrcEACpiw8rbuWjZDMQFSWpDBRWu13O6yVQmFYLiaQ96u79B E+5A== X-Gm-Message-State: AAQBX9fzzs/qloZeZnwmv89q9MXl8ShO32M3yeXc8aqmmBn3+N9HCFYY kkQzsad7fv/fpOhXdC5XA47XTg== X-Received: by 2002:a05:6a20:2448:b0:e3:6fdb:f6c6 with SMTP id t8-20020a056a20244800b000e36fdbf6c6mr7927795pzc.6.1681564551984; Sat, 15 Apr 2023 06:15:51 -0700 (PDT) Received: from [192.168.4.201] (cpe-72-132-29-68.dc.res.rr.com. [72.132.29.68]) by smtp.gmail.com with ESMTPSA id a21-20020a1709027d9500b001a1cd6c5a88sm4661610plm.73.2023.04.15.06.15.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 15 Apr 2023 06:15:51 -0700 (PDT) Message-ID: Date: Sat, 15 Apr 2023 07:15:49 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 1/2] fs: add FMODE_DIO_PARALLEL_WRITE flag Content-Language: en-US To: "Darrick J. Wong" , Christoph Hellwig Cc: Miklos Szeredi , Bernd Schubert , io-uring@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, dsingh@ddn.com References: <20230307172015.54911-2-axboe@kernel.dk> <20230412134057.381941-1-bschubert@ddn.com> <20230414153612.GB360881@frogsfrogsfrogs> From: Jens Axboe In-Reply-To: <20230414153612.GB360881@frogsfrogsfrogs> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On 4/14/23 9:36?AM, Darrick J. Wong wrote: > On Thu, Apr 13, 2023 at 10:11:28PM -0700, Christoph Hellwig wrote: >> On Thu, Apr 13, 2023 at 09:40:29AM +0200, Miklos Szeredi wrote: >>> fuse_direct_write_iter(): >>> >>> bool exclusive_lock = >>> !(ff->open_flags & FOPEN_PARALLEL_DIRECT_WRITES) || >>> iocb->ki_flags & IOCB_APPEND || >>> fuse_direct_write_extending_i_size(iocb, from); >>> >>> If the write is size extending, then it will take the lock exclusive. >>> OTOH, I guess that it would be unusual for lots of size extending >>> writes to be done in parallel. >>> >>> What would be the effect of giving the FMODE_DIO_PARALLEL_WRITE hint >>> and then still serializing the writes? >> >> I have no idea how this flags work, but XFS also takes i_rwsem >> exclusively for appends, when the positions and size aren't aligned to >> the block size, and a few other cases. > > IIUC uring wants to avoid the situation where someone sends 300 writes > to the same file, all of which end up in background workers, and all of > which then contend on exclusive i_rwsem. Hence it has some hashing > scheme that executes io requests serially if they hash to the same value > (which iirc is the inode number?) to prevent resource waste. > > This flag turns off that hashing behavior on the assumption that each of > those 300 writes won't serialize on the other 299 writes, hence it's ok > to start up 300 workers. > > (apologies for precoffee garbled response) Yep, that is pretty much it. If all writes to that inode are serialized by a lock on the fs side, then we'll get a lot of contention on that mutex. And since, originally, nothing supported async writes, everything would get punted to the io-wq workers. io_uring added per-inode hashing for this, so that any punt to io-wq of a write would get serialized. IOW, it's an efficiency thing, not a correctness thing. -- Jens Axboe