From nobody Tue May 30 23:49:23 2023 X-Original-To: questions@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 4QW8J90xVYz4YNFX for ; Tue, 30 May 2023 23:49:29 +0000 (UTC) (envelope-from sysadmin.lists@mailfence.com) Received: from wilbur.contactoffice.com (wilbur.contactoffice.com [212.3.242.68]) (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 4QW8J84n4Wz3l3N for ; Tue, 30 May 2023 23:49:28 +0000 (UTC) (envelope-from sysadmin.lists@mailfence.com) Authentication-Results: mx1.freebsd.org; none Received: from ichabod.co-bxl (ichabod.co-bxl [10.2.0.36]) by wilbur.contactoffice.com (Postfix) with ESMTP id A6685AE7; Wed, 31 May 2023 01:49:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1685490566; s=20210208-e7xh; d=mailfence.com; i=sysadmin.lists@mailfence.com; h=Date:From:To:Message-ID:In-Reply-To:References:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1927; bh=VbiM8dZiRegkf8ifvrGgKDssbVBaZ+Nxp0NDJ6PQA88=; b=KjbPj6TE/1D6LO352OaYcAT5m8hSM2YUQ14Fb1xgV+eBLeSCPQRZ5TFPUq6gWUGl 8XMPOGBSBzI71na19AyQVxzwQGUuJtx0xKmlbJk3DuyYyexYBfNF34+b4FQ45bNwAtZ v8A9OAhGSDeGJ3ZueAQMlitU6eexIH6FyMZ622gxAPz7b4bt3FA0o4A64QCxLttlkLm NCAVQoo/rEzdVtVWUJFAlKYHhHrv9O3GyCCkfT5uHErUFZe1X9rBeHWU9roumHf3Dwj WL0y8kH8nKhOg4afhjobDq9LzMgrwtNtip2ZjMb80dqYzfZBax6waNOP2z8TKcIDNn+ 4I9CWHc0hQ== Date: Wed, 31 May 2023 01:49:23 +0200 (CEST) From: Sysadmin Lists To: questions@freebsd.org, David Christensen Message-ID: <343655931.86727.1685490563032@ichabod.co-bxl> In-Reply-To: References: <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> Subject: Re: read and write back full disk to trigger relocation List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailer: ContactOffice Mail X-ContactOffice-Account: com:312482426 X-Rspamd-Queue-Id: 4QW8J84n4Wz3l3N X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:10753, ipnet:212.3.242.64/26, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N > ---------------------------------------- > From: David Christensen > Date: May 30, 2023, 4:16:09 PM > To: > 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