From owner-freebsd-fs@freebsd.org Sat Jul 27 17:17:25 2019 Return-Path: Delivered-To: freebsd-fs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 06D8CBE243 for ; Sat, 27 Jul 2019 17:17:25 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 561F98DA09 for ; Sat, 27 Jul 2019 17:17:24 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io1-f66.google.com with SMTP id s7so111190876iob.11 for ; Sat, 27 Jul 2019 10:17:24 -0700 (PDT) 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:reply-to :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=Gf+p+PP7x7Pp5W9KMWFwjCYzSMvDB+bq/OEo4BM9ZP4=; b=X8bCCpcj1QiqVUi/v5JUl6107AdIANZPFyHaVQp7TvxjTCspjU9mlhXJYS+3XA64wl LTPKpYB961bj9hloeEDlyYfRlfpCZUTHfOCVaZGmqob2A3NnGQEmOmET+jmvvuqezwlb 3rv3stZ2A5Wn0ai5+O1OxN0I/NxzjyHyFrk++dRwo0gVWqbOMsb1QgevRYamK9GQIQZa nuRr78gTCrxezFp6xYrS0nmxQSqc7Ud9x8tSQQhQh9/KE1FIhbKIdA3yWkEiWtCwrfCf IUXACRKWiKMGx0rkEwsfYZiQWgLHucTuNIcvq6QWa766MskAh/lXA8+dMWzPG6W118oq ZYPA== X-Gm-Message-State: APjAAAUW+1rk9OnIEnxqal4zx/5IipD/8zCoPTOB5QG7V7F9KTJr5KJf IxUs+svsed7NmAJScERhmWOp1Fhq X-Google-Smtp-Source: APXvYqyfBx8gD1Gm/uh+hD/d3H3o/gv7UjdeVWgzASTpOdGjknldy0psPYUbdFX2stc9SMb1r7FwrA== X-Received: by 2002:a5d:8416:: with SMTP id i22mr68120240ion.248.1564247842072; Sat, 27 Jul 2019 10:17:22 -0700 (PDT) Received: from mail-io1-f43.google.com (mail-io1-f43.google.com. [209.85.166.43]) by smtp.gmail.com with ESMTPSA id z19sm66373818ioh.12.2019.07.27.10.17.21 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jul 2019 10:17:21 -0700 (PDT) Received: by mail-io1-f43.google.com with SMTP id z3so1630882iog.0 for ; Sat, 27 Jul 2019 10:17:21 -0700 (PDT) X-Received: by 2002:a5d:88c6:: with SMTP id i6mr71991428iol.107.1564247840934; Sat, 27 Jul 2019 10:17:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: cem@freebsd.org From: Conrad Meyer Date: Sat, 27 Jul 2019 10:17:10 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: RFC: should copy_file_range(2) use size_t or off_t for length argument To: Rick Macklem Cc: "freebsd-fs@freebsd.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 561F98DA09 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of csecem@gmail.com designates 209.85.166.66 as permitted sender) smtp.mailfrom=csecem@gmail.com X-Spamd-Result: default: False [-4.21 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[cem@freebsd.org]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; REPLYTO_ADDR_EQ_FROM(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.91)[-0.908,0]; FORGED_SENDER(0.30)[cem@freebsd.org,csecem@gmail.com]; IP_SCORE(-1.29)[ip: (-0.55), ipnet: 209.85.128.0/17(-3.42), asn: 15169(-2.44), country: US(-0.05)]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; TAGGED_FROM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; FROM_NEQ_ENVFROM(0.00)[cem@freebsd.org,csecem@gmail.com]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-fs@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[66.166.85.209.list.dnswl.org : 127.0.5.0]; RCVD_TLS_LAST(0.00)[] X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jul 2019 17:17:25 -0000 Just my 2=C2=A2: keep the 1:1 Linux compatible interface. Requiring programs to loop over N x 2^31 copies of larger files on 32-bit platforms does not impose significant extra syscall burden on copy programs over the wider off_t, and it fits the pattern of many existing synchronous IO APIs (size_t lengths). I think there is some benefit to matching other OS's non-POSIX function APIs exactly when we choose to use those same names and concepts =E2=80=94 ifdef soup is painful. And developers target Linux firs= t. Cheers, Conrad On Sat, Jul 27, 2019 at 9:40 AM Rick Macklem wrote: > > Hi, > > r350315 implemented a Linux compatible copy_file_range(2) syscall. > Since Linux used a length argument of size_t and a return argument > type of ssize_t, I did the same. > > Kostik has suggested that making these off_t would allow a full 64bit > copy be done on 32bit arches. > Here is the snippet of discussion we have had: > Kostik Belousov wrote: > > >Kostik Belousov wrote: > >> >I sat to write the compat32 shims, and only then noted that len has s= ize_t > >> >type. Why is it size_t and not off_t ? > > I wrote: > >> Well, that's what Linux did. > >> > >> Also, since it returns ssize_t, it can't do more than SSIZE_MAX > >> (generally 1/2 of SIZE_T_MAX). Returning ssize_t is also what Linux > >> does and is consistent with read(2)/write(2). > > > >If changing the length argument type to off_t, it is reasonable to chang= e > >the return type to off_t as well. We already have the lseek(2) syscall = that > >requires two return registers on 32bit. > > > >Note that it is reasonable for read(2) to take length as size_t-typed > >parameter, because size_t is the type for object sizes. There is no > >object in user address space for copy_file_range(2) API, so potentially > >wider off_t is acceptable and is in fact useful there. It is useful on > >32bit machines where FreeBSD size_t is 32bit, while off_t is 64bit. > > So, what do others think? > (My only concern w.r.t. changing the arguments to off_t is Linux compatib= ility.) > > rick > _______________________________________________ > freebsd-fs@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-fs > To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org"