From nobody Fri Jan 24 19:10:01 2025 X-Original-To: freebsd-geom@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 4YfnSX1XLQz5lnD2 for ; Fri, 24 Jan 2025 19:10:04 +0000 (UTC) (envelope-from jonny@lists.freebsd.org.olpp.net) Received: from platon.bruckbu.de (platon.bruckbu.de [5.252.225.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4YfnSW3PL0z3McV for ; Fri, 24 Jan 2025 19:10:03 +0000 (UTC) (envelope-from jonny@lists.freebsd.org.olpp.net) Authentication-Results: mx1.freebsd.org; dkim=none; spf=none (mx1.freebsd.org: domain of jonny@lists.freebsd.org.olpp.net has no SPF policy when checking 5.252.225.229) smtp.mailfrom=jonny@lists.freebsd.org.olpp.net; dmarc=none Received: from platon.bruckbu.de (localhost [IPv6:::1]) by platon.bruckbu.de (Postfix) with ESMTP id 86ED46B026; Fri, 24 Jan 2025 20:10:01 +0100 (CET) Received: from [IPV6:2001:9e8:b408:3400:bdcc:5e47:41b2:de5] ([2001:9e8:b408:3400:bdcc:5e47:41b2:de5]) by platon.bruckbu.de with ESMTPSA id PgccH4nlk2e9PA0AJN8Uxw (envelope-from ); Fri, 24 Jan 2025 20:10:01 +0100 Message-ID: Date: Fri, 24 Jan 2025 20:10:01 +0100 List-Id: GEOM-specific discussions and implementations List-Archive: https://lists.freebsd.org/archives/freebsd-geom List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-geom@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Jonathan Krebs Subject: when does BIO_FLUSH happen on a disk? To: freebsd-geom@FreeBSD.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [0.39 / 15.00]; AUTH_NA(1.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_LONG(-0.99)[-0.992]; NEURAL_HAM_SHORT(-0.99)[-0.986]; NEURAL_SPAM_MEDIUM(0.67)[0.665]; RCVD_IN_DNSWL_MED(-0.20)[5.252.225.229:from]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:197540, ipnet:5.252.224.0/22, country:DE]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MLMMJ_DEST(0.00)[freebsd-geom@FreeBSD.org]; DMARC_NA(0.00)[olpp.net]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_NA(0.00)[no SPF record] X-Spamd-Bar: / X-Rspamd-Queue-Id: 4YfnSW3PL0z3McV Dear FreeBSD developers, Inside a QEMU-VM, I inserted calls to g_print_bio in the first lines of sys/cam/ata/ata_da.c:adastrategy() and sys/dev/virtio/block/virtio_blk.c:vtblk_strategy() of a FreeBSD 14.2, and added an image file with -drive file=test.img,format=raw[,if=virtio]. While using the virtual disk, I observe BIO_WRITE request, but never a BIO_FLUSH. Usage was by - creating a UFS filesystem (newfs /dev/vtbd0) - mounting it in /mnt - write a file with dd of=/mnt/a bs=4k count=20 if=/dev/urandom sync dd of=/mnt/a bs=4k count=20 if=/dev/urandom conv=fdatasync dd of=/mnt/a bs=4k count=20 if=/dev/urandom oflag=sync - repeating this with a geli layer (no special parameters to geli init) and with msdosfs instead of UFS The differences between the dd calls with and without sync options was that the WRITEs were immediately issued with conv=fdatasync or oflag=sync, but no FLUSHs were observed (with one exception: geli clear) This is why I wonder when BIO_FLUSH is used and if it means something different. I am interested for these reasons: - In a university research project, I am trying to suspend+resume a system without calling the DEVICE_SUSPEND functions. Therefore I wonder when I can assume that a BIO_WRITE has really arrived on disk - The GELI class seems to reorder WRITEs and FLUSHes. (at least in my understanding while looking for code example on writing a geom class) This was also discussed here 12 years ago, where I could not find a resolution: https://freebsd-geom.freebsd.narkive.com/KruBpS7r/geli-and-bio-flush-and-or-bio-ordered-issue (writes are queued, flush is passed g_down immediately, https://cgit.freebsd.org/src/tree/sys/geom/eli/g_eli.c#n507 ) Thanks and Happy Hacking, thejonny