From nobody Wed Sep 20 23:52:20 2023 X-Original-To: freebsd-fs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rrb1Z1VBhz4vLhb for ; Wed, 20 Sep 2023 23:52:34 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com [209.85.221.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rrb1Y3sCyz4g9G; Wed, 20 Sep 2023 23:52:33 +0000 (UTC) (envelope-from asomers@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=none; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.221.170 as permitted sender) smtp.mailfrom=asomers@gmail.com; dmarc=none Received: by mail-vk1-f170.google.com with SMTP id 71dfb90a1353d-493639d616eso173369e0c.0; Wed, 20 Sep 2023 16:52:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695253952; x=1695858752; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Njwgl+mrQhZRCCVM6ZzZVQpfmkCF3oVQA7HDoTBF+Pg=; b=uyJzgqcl21Vd7x0+/X22AZgw5o8EvjFb9sgyIAXAuARrGAcNvbO15j1zNARtZ+nsrZ PAr53LsIkqd3zlXk4wms37+dF0k++3dSAuR0LJXX1LDNzpItu6l8bm28VDrl6B0p89h8 cDYW2dbZxIkEHO2etqWWWckYzNBt5tKMpzT4bNXOGF7vupgJrg57TAKt/GbirxNmrGW+ mXH1qMaR5SH+tYOTZw/K/VOQMEAfzmEDQMxuzP10+Juf55pnMXt6Z/6PnBI5EkmqNUqH kYEDkGLqT4FSJ/JrKNlfu6bqQiS/CdS1XHT+n7HwS13rEivI5iOL9UO0ma5Nt3atKiFa BXKw== X-Gm-Message-State: AOJu0YwMrKRVGs2d3DML/7vBW5McY3V+OPQJMldj6aGI5y1n3lZgPo1y ykeMKm9YcxMJ2Sji4zNJKUgNZbEuRCT/c0JM6zok6HIZ X-Google-Smtp-Source: AGHT+IEQi5kImnKrFLVIq7uiZPA87T+ah/wX/oVJpxh6cYPV5RaAk9mSxgV3LrH9k2EnwXzIqcQIFPHSPvMXrBzrWeY= X-Received: by 2002:a1f:6243:0:b0:486:de54:b11 with SMTP id w64-20020a1f6243000000b00486de540b11mr3355053vkb.16.1695253951981; Wed, 20 Sep 2023 16:52:31 -0700 (PDT) List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Alan Somers Date: Wed, 20 Sep 2023 16:52:20 -0700 Message-ID: Subject: Re: RFC: Should copy_file_range(2) work for shared memory objects? To: Rick Macklem Cc: Alan Somers , Freebsd fs Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: + X-Spamd-Result: default: False [1.14 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_LONG(-1.00)[-0.999]; NEURAL_SPAM_SHORT(0.68)[0.683]; NEURAL_SPAM_MEDIUM(0.46)[0.457]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_THREE(0.00)[3]; RCVD_IN_DNSWL_NONE(0.00)[209.85.221.170:from]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TAGGED_RCPT(0.00)[]; DMARC_NA(0.00)[freebsd.org]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[asomers]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_COUNT_ONE(0.00)[1]; TO_DN_ALL(0.00)[]; MLMMJ_DEST(0.00)[freebsd-fs@freebsd.org]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.221.170:from] X-Rspamd-Queue-Id: 4Rrb1Y3sCyz4g9G On Wed, Sep 20, 2023 at 4:47=E2=80=AFPM Rick Macklem wrote: > > On Wed, Sep 20, 2023 at 4:21=E2=80=AFPM Rick Macklem wrote: > > > > On Wed, Sep 20, 2023 at 4:09=E2=80=AFPM Rick Macklem wrote: > > > > > > On Wed, Sep 20, 2023 at 3:07=E2=80=AFPM Alan Somers wrote: > > > > > > > > On Wed, Sep 20, 2023 at 3:05=E2=80=AFPM Rick Macklem wrote: > > > > > > > > > > Right now (as noted by PR#273962) copy_file_range(2) > > > > > fails for shared memory objects because there is no > > > > > vnode (f_vnode =3D=3D NULL) for them and the code uses > > > > > vnodes (including a file system specific VOP_COPY_FILE_RANGE(9)). > > > > > > > > > > Do you think copy_file_range(2) should work for shared memory obj= ects? > > > > > > > > > > This would require specific handling in kern_copy_file_range() > > > > > to work. I do not think the patch would be a lot of work, but > > > > > I am not familiar with the f_ops and shared memory code. > > > > > > > > > > rick > > > > > > > > This sounds annoying to fix. But I think we ought to. Right now > > > > programmers can assume that copy_file_range will work for every typ= e > > > > of file. We don't document an EOPNOTSUP error code or anything lik= e > > > > that. Does it work on sockets, too? > > > No. I guess I have a different definition of "file" (unless you meant > > > "filedesc"?). I cannot see how a "range is defined for sockets > > > or named pipes or...". It currently checks for a f_vnode, which > > > probably is not enough. (I haven't figured out what path_fileops > > > are, so I do not know if they work?) > > > > > > I can see how it can be implemented for shared memory objects. > > > However, this is going to take a fair amount of work, since they > > > do not use vnodes. > > > I think it goes something like this: > > > - Create a new fileops (f_copy_file_range), since it needs to use > > > the correct range lock variables (in shmfd instead of vnode ones). > > > - Move most of kern_copy_file_range() into vnodeop_copy_file_range() > > > and call f_copy_file_range() from kern_copy_file_range(). > > > - Create a shm_copy_file_range() that does the correct range locking > > > and then copies via uiomove(). > > > This would be a KABI change, so I do not think it could be MFC'd. > > > > > > I think there is a need for copy_file_range(2) to return EOPNOTSUP > > > for cases it will never handle. (I need to test AF_LOCAL sockets, > > > since I think they have vnodes?) > > copy_file_range(2) does currently return EOPNOTSUPP for unix > > domain (AF_LOCAL) sockets. The man page needs to be fixed, > > whether or not support for shared memory objects is added. > > > Oops, my mistake. It was the open(2) that failed with EOPNOTSUPP, > not copy_file_range(2). (I have a simple test program that open(2)s > file names and then uses copy_file_range(2) on the descriptors. > Btw, an open(2) with O_PATH works, but no data is copied. > Not sure if that should be considered correct behaviour? Do you mean that copy_file_range returns 0 for AF_LOCAL sockets? That sounds suspicious. 0 could be interpreted as EoF. Could you please share your test program?