Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp175346imu; Thu, 10 Jan 2019 21:13:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Pwtugc7ON9O/bUC1X16bpnSSqhpliXdItZ4Mbr53GjY5CqEe41vgm3MnwMOQGe7ermb+L X-Received: by 2002:a17:902:5ac7:: with SMTP id g7mr13421306plm.212.1547183591520; Thu, 10 Jan 2019 21:13:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547183591; cv=none; d=google.com; s=arc-20160816; b=lQXbV3cjD6riFRKf6CThXtHdnwGrrfjaJWe3PWfsBRKb8COlnMExiczwh2cAMkEeg7 6nZbozaSUmCKHE9FbZC6SBY0HA8v47XrW/BU++j7HHMG0hcifAj2Wb2o9gqIif1myLU3 oSxnTPLKdqXKOtsxUETzjciaJuBjYzg371pgqbrKno/VEpv7N52JSRisQBCIuWtlo3yH CaSIXKoQdIxGRtuS9hCDrS1KEe8N1A53Mw2z9PHWFWUxGsd5xwi42Yik3/JwI1McmNMI ZPbuGonQK7wMh0ieDop6KksFe2oHy3aWT6pbWnhDWCmBgU84+qOtJvj4deCsG5WlhPyH 0CMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=RkfDT/DdamgeXmHsKiNqXvMWEuq5XHT1H7rozNSeh3E=; b=zzJ4Yo+6S6e+o2wau1M0lXiQXBt4e2af2haAjGxr1t/ncMHD4oXEykwDJmwS+fqQTJ MW3l5P7CsvMeR/wIkpx8sTlZYw6ToJfkFRt72YEX3qEpbhtB+4l2MpFk2vkAF9tZK88c bBcufo+DGsYIWJ2YA4YZmJ/IYrIVY82GINbrtk8htHnCqQcTZfDvXGc1jSAGB7auibgP Sfan0PxNfC4OVlo6vX6C3vkCa5zYalQK3lYrE3CTU76j0pYbBAnWBFU22lMZIsAoo53q RZ0IHqhs20u4l6ghsgCuUFQUAKWJf1lQXz06QzYNWzEOOMmpMEQkvUlzkEPyGRGLOJQM rpeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R3QEIaJq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si25851888plc.241.2019.01.10.21.12.56; Thu, 10 Jan 2019 21:13:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R3QEIaJq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730017AbfAKCrP (ORCPT + 99 others); Thu, 10 Jan 2019 21:47:15 -0500 Received: from mail-ot1-f50.google.com ([209.85.210.50]:46742 "EHLO mail-ot1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729919AbfAKCrP (ORCPT ); Thu, 10 Jan 2019 21:47:15 -0500 Received: by mail-ot1-f50.google.com with SMTP id w25so11876209otm.13 for ; Thu, 10 Jan 2019 18:47:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RkfDT/DdamgeXmHsKiNqXvMWEuq5XHT1H7rozNSeh3E=; b=R3QEIaJqT540aMDIkEFhsf1ijyROofZNrBk70LpQYtdlaqte4BlzMxzQZCVWO62EjD 9ma3sI29VX3cLtpcvSsJ3Sk7krwx1L2rozOcg+YWsqEL740h7n9X431LIv34r8VgBVce 4RxJVD3fajtZiFTeMzx9fvENAN0HzvymEg1uCWZ984w9xz9N2O95ASiaLWexmRBi5fPJ RFuUlAxM2xQlY3gh6SrGijvbqfdvw/WNEe1d/+OFAM3xuJ4tDrYv6Hm/YrncEHhw3vTa 4Gghsuew/XoHKh/R5MBGcM3N3IBzlWR4++i8gmPEhaFbJwp/jDEIBY/CsLsQHm9SxIxh hBvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RkfDT/DdamgeXmHsKiNqXvMWEuq5XHT1H7rozNSeh3E=; b=LiRgWzyRWIgJeaFqfSnmMIvw/L+HZKty+kewb+4MKiZT5h4JoffYzrTb1HPc6ux/ax qjIBGsFdkapiJlVOulVgqa6wYCSzKaEv2ohdak9HZDUraTKBcU8+oOMV3gMraiKzycqK Lu9qFWTvkPUH+vbTV3M7nxWVKeQ6PFnA97NLKHfPPpJohifjsel9C+ewjQrFZafUyqb0 lcP2o/mBuK5ap/s31ZHSKk3TDkwg7m3dHM5dKX7xCmE5rYWUUljYB5/cu2WiZEv5BOtg 8ivg6cWbYalnrBumLP+zFKFsj0OypdeXMIvIGGPIr9uwsdiuabXny/QahBFlY393CUZB 6T8Q== X-Gm-Message-State: AJcUukdIovzvKfmPm3gvg4BfB1Xogoiqr8xAEF1nn0IcBYYA4QXKg/ds hrfGODk7a4t1jUNe8lcKXAN9M2H/cwsrwB3FMBs= X-Received: by 2002:a9d:4f0e:: with SMTP id d14mr8868786otl.259.1547174834364; Thu, 10 Jan 2019 18:47:14 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: james harvey Date: Thu, 10 Jan 2019 21:47:03 -0500 Message-ID: Subject: Re: Interpreting /sys/block//{,}/discard_alignment To: "Martin K. Petersen" Cc: kernel list , jaxboe@fusionio.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 10, 2019 at 7:04 PM Martin K. Petersen wrote: > James, > > > Q1 - I'm hoping you can clarify how this should be interpreted. > > > > I originally took this to mean the number of bytes into the first > > discard_granularity block that the partition resides at. i.e. If > > discard_granularity_block is 128MB, and partition 1 starts at sector > > 2048 with 512 byte sectors, that this should return 2048*512=1048576 > > (1MB.) > > The alignment offset is the offset for the given block device. It > doesn't matter whether the block device in question is a partition, DM > device or a full device. A block device is a block device. > > The common alignment scenario is 3584 on a device with 4K physical > blocks. That's because of the 63-sector legacy FAT partition table > offset. Which essentially means that the first LBA is misaligned and the > first aligned HBA is 7. If I can double check I'm understanding you correctly, if: * Block device "A" has 512 byte sectors * A has a partition table with partition A1 starting at sector 2048 (1048576 bytes) * A and A1 have discard_granularity of 128MB (134217728 bytes) * A has discard_alignment of 0 Then A1 should have a discard_alignment of 1048576, not 133169152 (128MB - 512 bytes/sector * 2048 sectors)? > Many of the first 512e drives shipped with that intentional misalignment > as default. And you could switch it to 0-aligned via a jumper. These > days all drives are 0-aligned. > > > Q2 - At https://lkml.org/lkml/2018/12/5/1693 --- I saw you recently > > said "... there are not many devices that actually report a non-zero > > discard alignment..." Does this mean that every filesystem needs to > > look at the partition table to determine its correct value on its own, > > rather than using discard_alignment? > > No, it needs to look at the device topology for the block device it is > on. I don't believe we ever wired up an ioctl for the discard alignment > so you'll have to find your device in sysfs. There's an alignment ioctl > for the "regular" block alignment, though. Ahh, good. I took that the wrong way, originally worried you were saying the value of discard_alignment couldn't be trusted.