Date: Wed, 31 May 2023 01:49:23 +0200 (CEST) From: Sysadmin Lists <sysadmin.lists@mailfence.com> To: questions@freebsd.org, David Christensen <dpchrist@holgerdanske.com> Subject: Re: read and write back full disk to trigger relocation Message-ID: <343655931.86727.1685490563032@ichabod.co-bxl> In-Reply-To: <d5e6aa60-f42d-7fbb-32a4-c7fb450d3a71@holgerdanske.com> References: <a111b6a7-0bf8-d3b9-9611-a7fbf36635b3@artem.ru> <1957739901.520492.1685310340560@ichabod.co-bxl> <0d0186c5-9542-1af3-2ce3-e28480b4b6d7@holgerdanske.com> <1961596841.3509648.1685359514813@fidget.co-bxl> <00671d49-83b1-26a0-4e28-47eb0d7cb95c@holgerdanske.com> <2025846914.656453.1685438293844@ichabod.co-bxl> <d5e6aa60-f42d-7fbb-32a4-c7fb450d3a71@holgerdanske.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> ---------------------------------------- > From: David Christensen <dpchrist@holgerdanske.com> > Date: May 30, 2023, 4:16:09 PM > To: <questions@freebsd.org> > Subject: Re: read and write back full disk to trigger relocation > > > I would say the experiment should be repeated on real HDD's, but how do > I detect if identical data has being written to the platters? The HDD > controller also has a cache and could optimize away such writes. > > Isn't that what dd is claiming authoritatively to be doing? Otherwise, putting that example in the manpage is dangerous and can lead to unexpected data loss. I don't speak C++ very good, but here's the source: https://github.com/coreutils/coreutils/blob/master/src/dd.c /* Write to FD the buffer BUF of size SIZE, processing any signals that arrive. Return the number of bytes written, setting errno if this is less than SIZE. Keep trying if there are partial writes. */ static idx_t iwrite (int fd, char const *buf, idx_t size) { idx_t total_written = 0; if ((output_flags & O_DIRECT) && size < output_blocksize) { int old_flags = fcntl (STDOUT_FILENO, F_GETFL); if (fcntl (STDOUT_FILENO, F_SETFL, old_flags & ~O_DIRECT) != 0 && status_level != STATUS_NONE) diagnose (errno, _("failed to turn off O_DIRECT: %s"), quotef (output_file)); /* Since we have just turned off O_DIRECT for the final write, we try to preserve some of its semantics. */ /* Call invalidate_cache to setup the appropriate offsets for subsequent calls. */ o_nocache_eof = true; invalidate_cache (STDOUT_FILENO, 0); /* Attempt to ensure that that final block is committed to stable storage as quickly as possible. */ conversions_mask |= C_FSYNC; /* After the subsequent fsync we'll call invalidate_cache to attempt to clear all data from the page cache. */ } -- Sent with https://mailfence.com Secure and private email
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?343655931.86727.1685490563032>