From owner-freebsd-hackers@freebsd.org Mon Mar 2 00:46:38 2020 Return-Path: Delivered-To: freebsd-hackers@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 8F9042542FF for ; Mon, 2 Mar 2020 00:46:38 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from smtp.digiware.nl (smtp.digiware.nl [IPv6:2001:4cb8:90:ffff::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48W1g04RYqz45yj for ; Mon, 2 Mar 2020 00:46:36 +0000 (UTC) (envelope-from wjw@digiware.nl) Received: from router.digiware.nl (localhost.digiware.nl [127.0.0.1]) by smtp.digiware.nl (Postfix) with ESMTP id 3A2A673395; Mon, 2 Mar 2020 01:46:27 +0100 (CET) X-Virus-Scanned: amavisd-new at digiware.com Received: from smtp.digiware.nl ([127.0.0.1]) by router.digiware.nl (router.digiware.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GyDUa8jw8M4C; Mon, 2 Mar 2020 01:46:26 +0100 (CET) Received: from [192.168.10.9] (vaio [192.168.10.9]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp.digiware.nl (Postfix) with ESMTPSA id AB2C673391 for ; Mon, 2 Mar 2020 01:46:26 +0100 (CET) To: FreeBSD Hackers From: Willem Jan Withagen Subject: What is the exact function of the offset parameter in preadv?? Message-ID: Date: Mon, 2 Mar 2020 01:46:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Firefox/68.0 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Content-Language: nl X-Rspamd-Queue-Id: 48W1g04RYqz45yj X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of wjw@digiware.nl designates 2001:4cb8:90:ffff::3 as permitted sender) smtp.mailfrom=wjw@digiware.nl X-Spamd-Result: default: False [-4.36 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[4]; RCVD_TLS_LAST(0.00)[]; TO_DN_ALL(0.00)[]; DMARC_NA(0.00)[digiware.nl]; IP_SCORE(-3.07)[ip: (-9.44), ipnet: 2001:4cb8::/29(-4.62), asn: 28878(-1.30), country: NL(0.03)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:28878, ipnet:2001:4cb8::/29, country:NL]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Mar 2020 00:46:38 -0000 Hi, Tried looking in the manual page, but it does not really describes what off_t offset does with a preadv... I suspect that is the offset in the file to start reading from? Next question is: What if the value is negative?     Are we then reading from the end of the file/device if it is     seekable? Manual page says:  The pread() and preadv() system calls may also return the following      errors:      [EINVAL]           The offset value was negative. But then I have this behyve code that gets calls like: block_proc_read: buf=0x0, cnt=1, len=512, off=-1024(0xfffffc00). block_proc_read: buf=0x0, cnt=1, len=512, off=-512(0xfffffe00). block_proc_read: buf=0x0, cnt=1, len=512, off=-1024(0xfffffc00). block_proc_read: buf=0x0, cnt=1, len=512, off=-512(0xfffffe00). block_proc_read: buf=0x0, cnt=1, len=512, off=-512(0xfffffe00). block_proc_read: buf=0x0, cnt=1, len=2048, off=-32256(0xffff8200). block_proc_read: buf=0x0, cnt=1, len=512, off=512(0x200). block_proc_read: buf=0x0, cnt=1, len=512, off=0(0x0). block_proc_read: buf=0x0, cnt=1, len=512, off=512(0x200). block_proc_read: buf=0x0, cnt=1, len=512, off=0(0x0). block_proc_read: buf=0x0, cnt=1, len=512, off=512(0x200). block_proc_read: buf=0x0, cnt=1, len=16384, off=1024(0x400). block_proc_read: buf=0x0, cnt=1, len=512, off=-512(0xfffffe00). block_proc_read: buf=0x0, cnt=1, len=16384, off=-16896(0xffffbe00). block_proc_read: buf=0x0, cnt=1, len=512, off=-512(0xfffffe00). Where these are the very first calls that a bhyve loaded image executes. which I guess is for probing the bootdisk to see where/what it needs to mount a root disk. Below bhyve boot output of a not working boot, and a working boot. The read trace above is from the working bhyve boot. So what are the negative offsets? --WjW Compare Using block_rbd_read for reading from a Rados device ============= vtblk0: on virtio_pci1 vtblk0: 134217727MB (34359738366 4096 byte sectors) ahci0: mem 0xc0004000-0xc00043ff irq 18 at device 4.0 on pci0 ahci0: AHCI v1.30 with 6 6Gbps ports, Port Multiplier not supported atkbdc0: port 0x60,0x64 irq 1 on acpi0 atkbd0: irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED] driver bug: Unable to set devclass (class: atkbdc devname: (unknown)) psm0: irq 12 on atkbdc0 psm0: [GIANT-LOCKED] psm0: model Generic PS/2 mouse, device ID 0 uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0 uart0: console (9600,n,8,1) uart1: <16550 or compatible> port 0x2f8-0x2ff irq 3 on acpi0 vga0: at port 0x3b0-0x3bb iomem 0xb0000-0xb7fff pnpid PNP0900 on isa0 Timecounters tick every 10.000 msec usb_needs_explore_all: no devclass Trying to mount root from ufs:/dev/ada0p2 [rw]... mountroot: waiting for device /dev/ada0p2... Mounting from ufs:/dev/ada0p2 failed with error 19. Loader variables:   vfs.root.mountfrom=ufs:/dev/ada0p2   vfs.root.mountfrom.options=rw Manual root filesystem specification:   : [options]       Mount using filesystem       and with the specified (optional) option list.     eg. ufs:/dev/da0s1a         zfs:zroot/ROOT/default         cd9660:/dev/cd0 ro           (which is equivalent to: mount -t cd9660 -o ro /dev/cd0 /)   ?               List valid disk boot devices   .               Yield 1 second (for background tasks)       Abort manual input ============= With booting from a normal file device: atkbdc0: port 0x60,0x64 irq 1 on acpi0 atkbd0: irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED] driver bug: Unable to set devclass (class: atkbdc devname: (unknown)) psm0: irq 12 on atkbdc0 psm0: [GIANT-LOCKED] psm0: model Generic PS/2 mouse, device ID 0 uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0 uart0: console (9600,n,8,1) uart1: <16550 or compatible> port 0x2f8-0x2ff irq 3 on acpi0 vga0: at port 0x3b0-0x3bb iomem 0xb0000-0xb7fff pnpid PNP0900 on isa0 Timecounters tick every 10.000 msec usb_needs_explore_all: no devclass Trying to mount root from ufs:/dev/ada0p2 [rw]... Root mount waiting for: CAM ada0 at ahcich0 bus 0 scbus0 target 0 lun 0 ada0: ACS-2 ATA SATA 3.x device ada0: Serial Number BHYVE-8C7D-D922-AD47 ada0: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 8192bytes) ada0: Command Queueing enabled ada0: 20480MB (41943040 512 byte sectors) ada1 at ahcich6 bus 0 scbus1 target 0 lun 0 ada1: ACS-2 ATA SATA 3.x device ada1: Serial Number BHYVE-4318-7904-5D51 ada1: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 8192bytes) ada1: Command Queueing enabled ada1: 20480MB (41943040 512 byte sectors) mountroot: waiting for device /dev/ada0p2... WARNING: / was not properly dismounted WARNING: /: mount pending error: blocks 168 files 1 ==========