From nobody Sun Oct 20 00:34:49 2024 X-Original-To: dev-commits-src-all@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 4XWKG20v1xz5ZWQG; Sun, 20 Oct 2024 00:34:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XWKG162pFz4Zdd; Sun, 20 Oct 2024 00:34:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729384489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LamU7lY5Ew8IRPJyioY9eIi9u06RlOJ+EEhltU6C2to=; b=ODxkJHxYcawg2qas46a4nrEW/8uH0V5iw0oSJvkfnSbV57t7x2/GuapjalWf8vQoIH32ir GrMQAlCoOamCJq8pqU5HqkVitU/Woicu6f9JENGf52jcnhJ4BXie5ZFSkYAHadA4Dtpp4W z4EasgUm9mlfRz2jiy2toqxrfx/iBlHHIWw41lHeluYl4fkqiwhfDYpW9qHnnkczl7fn5r KYRL5TgmHNOPFZQJ7aJhwM/8vN+Pe4hmYOOdBxYMhGtjDyEuA8nX1WgSmdWyZR3xam9BnZ 948TzGHIANYRdR6aLeTtX3HIxwfsweFuvPFFjcJaene0RnDcZDSGjuM0oxTENQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729384489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LamU7lY5Ew8IRPJyioY9eIi9u06RlOJ+EEhltU6C2to=; b=IiqNgBLEQRkd1Vz33MtTvhxAdRBPjTbSnD8tJDqGABTNy2ZECi3i+GXg1wYtq1yYYoTQlQ zyLpCJjwYPtXNLicuBstbYFMIsBYlMSuh/Sl3OvW/ftAo8Ot4FeN/d+STIoFFFeJayj00R Bd/6H5lfQYFBlNrS9Kx8NYtTKpcPGq9fIraUKf97WTZmNPb/v0TF9O8YzJKdInAzR04o7Q W2kXQxPJsb9ALv6rzxhelofljj6QWkvhDybaNV3Fje3wp564SQMQgnoClXLT+PKKnxf0b5 JcoiZcJjPZCnONnkidJjA/YAaBB60J4oP/9awzJMKajvcihy6pg8KJsznMBmgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729384489; a=rsa-sha256; cv=none; b=P89p57WmFL5DUVMWzVKFCc0ahlCiqizj25AU2iqMC2FMLmMETmBKsdBpuz2D9wYZ8S2Hlu Qh4NBYwkj3e0VV83QhDENsX854F0kgQyyK2YbyUAQ2EDRBVlieKs6WLQvF409uHPTvfmlB v/H3P9LoUEdto00J2jbOPkhu8SBc0dkJ57bZFCFXQNCMoonEjYpjO05cITyXxlTYbywHqk g+wxj0eugvK+IZ0raxiS9teZnxY1LvlQHU2KjV0D+by6hMsI39ot4GAkT1AZAz3DX4IqJq PimJlvEM3zVhG2mcPx2AnN7WsXwwp9rQrhKXICWpzU37D9P2kYLmSI1+4IwWTA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XWKG15fzxzg01; Sun, 20 Oct 2024 00:34:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49K0Yn7U061520; Sun, 20 Oct 2024 00:34:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49K0YnnZ061517; Sun, 20 Oct 2024 00:34:49 GMT (envelope-from git) Date: Sun, 20 Oct 2024 00:34:49 GMT Message-Id: <202410200034.49K0YnnZ061517@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 959f0d0cdb14 - stable/14 - md(4): always trim the last partial sector List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 959f0d0cdb1482d754f24b7ae16bda0ac2e7b31a Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=959f0d0cdb1482d754f24b7ae16bda0ac2e7b31a commit 959f0d0cdb1482d754f24b7ae16bda0ac2e7b31a Author: Konstantin Belousov AuthorDate: 2024-10-13 21:28:22 +0000 Commit: Konstantin Belousov CommitDate: 2024-10-20 00:33:04 +0000 md(4): always trim the last partial sector PR: 281978 (cherry picked from commit 4bf34c597c44a2393ac5ec483e9cecac128d8202) --- sys/dev/md/md.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 1d531b88193f..3285cfef830d 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -1303,6 +1303,7 @@ mdinit(struct md_s *sc) { struct g_geom *gp; struct g_provider *pp; + unsigned remn; g_topology_lock(); gp = g_new_geomf(&g_md_class, "md%d", sc->unit); @@ -1311,6 +1312,13 @@ mdinit(struct md_s *sc) devstat_remove_entry(pp->stat); pp->stat = NULL; pp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE; + /* Prune off any residual fractional sector. */ + remn = sc->mediasize % sc->sectorsize; + if (remn != 0) { + printf("md%d: truncating fractional last sector by %u bytes\n", + sc->unit, remn); + sc->mediasize -= remn; + } pp->mediasize = sc->mediasize; pp->sectorsize = sc->sectorsize; switch (sc->type) { @@ -1680,7 +1688,7 @@ kern_mdattach_locked(struct thread *td, struct md_req *mdr) { struct md_s *sc; unsigned sectsize; - int error, i; + int error; sx_assert(&md_sx, SA_XLOCKED); @@ -1752,10 +1760,6 @@ err_after_new: return (error); } - /* Prune off any residual fractional sector */ - i = sc->mediasize % sc->sectorsize; - sc->mediasize -= i; - mdinit(sc); return (0); }