Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp996615pxj; Thu, 17 Jun 2021 19:41:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynAQbligSSZPiMK4zfKVdD3Uyt5YkUZ2Pbvto7jl+N8IMjEzv+CA7uATTWnknlLM3811gf X-Received: by 2002:a05:6e02:1809:: with SMTP id a9mr5692757ilv.221.1623984074247; Thu, 17 Jun 2021 19:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623984074; cv=none; d=google.com; s=arc-20160816; b=ru28T+XdknAYp/pj5Dvr/XtZTy6XNjG9GWu6CcrWHfKgkxC+NQokO1fX2wu0Q10HZu 9FqXfcfZPHK0BYBPpHbg60p3IoJinLx8Z/MOjHzCh+DqPsAL3IhIfDcwMOiban+LCW3u /xjIUtTHrS2iC6jzwulcSCveox+X7jiLDjUkAFQUPTjNPX8iWjmQ02bV5+xyMN031mlR Myj+DlvFBx5v8vJ3kQb/3DlCas2jQFaTEYDn6AT0z0WZBMkLx6eCUpYFZuYh+hxbgIrT DILo+kivLpvETkX8BUQOh+aiplYNK+8px6qDF5GMB8dxWDVLjRM+PjT/m8vD8Js6gncl LQFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:from; bh=Q7RbCKgSk5h1jem9dXNZ5yqfit5y4sv6R9H/UHSF8xg=; b=xI7kKXCWQNDLHXWxPLvVIPJeVS1po4EYZtIjFT1vKr073RvjkYJVPmYJsDEDjtEfEB n5kLi6TH0a0GB81qH3TsgNDSxuDTzcNWk8C/ZhwdKKxss8YQNrmXl87Y8uV7F/TQopLj 1DV4SUTcBFsUFHW3CZd4CxhDNiv915WGk5qFYBXJOL6vViCC1I5bQpV/71BqZtlq/msv j8e57JPAtPZzu1+cy2iCLjj8xEWEBC4koMVb+xuwBQvLAVIeLNNdORtDvWUAIaFveAB/ NW9m7Cc3Gap59EhQ94vczYg538mHf2W43sCYEoNT5TowvzCSNa6QGa0kZPKC7vTGdAeL oXbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@klausen.dk header.s=dkim header.b=18dAxXYS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=klausen.dk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si994578ilj.131.2021.06.17.19.41.02; Thu, 17 Jun 2021 19:41:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@klausen.dk header.s=dkim header.b=18dAxXYS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=klausen.dk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbhFQWO3 (ORCPT + 99 others); Thu, 17 Jun 2021 18:14:29 -0400 Received: from mail.klausen.dk ([157.90.24.29]:51186 "EHLO mail.klausen.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbhFQWO2 (ORCPT ); Thu, 17 Jun 2021 18:14:28 -0400 From: Kristian Klausen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=klausen.dk; s=dkim; t=1623967938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Q7RbCKgSk5h1jem9dXNZ5yqfit5y4sv6R9H/UHSF8xg=; b=18dAxXYSeh3O6HtlKbvDbc35tXLIHZCBiVTqkScX+7q5NKHJdIijAy8GnBMMGR1TIcPYSv HKyn6VJeqFrNPy3WmpjeYQmueaLiwXhxTO7GJY1ofEAjSK4pOEsY1oBiwrbCZexKYhSQmJ 1WA2QzQKBxTgtuGxi5E/yqxt8WU/404= To: linux-block@vger.kernel.org Cc: Kristian Klausen , stable@vger.kernel.org, Jens Axboe , Martijn Coenen , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] loop: Fix missing discard support when using LOOP_CONFIGURE Date: Fri, 18 Jun 2021 00:11:57 +0200 Message-Id: <20210617221158.7045-1-kristian@klausen.dk> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cc: # 5.8.x- Fixes: 3448914e8cc5 ("loop: Add LOOP_CONFIGURE ioctl") Signed-off-by: Kristian Klausen --- Tested like so (without the patch): losetup 2.37<= uses LOOP_CONFIGURE instead of LOOP_SET_STATUS64[1] # fallocate -l100M disk.img # rmmod loop # losetup --version losetup from util-linux 2.36.2 # losetup --find --show disk.img /dev/loop0 # grep '' /sys/devices/virtual/block/loop0/queue/*discard* /sys/devices/virtual/block/loop0/queue/discard_granularity:4096 /sys/devices/virtual/block/loop0/queue/discard_max_bytes:4294966784 /sys/devices/virtual/block/loop0/queue/discard_max_hw_bytes:4294966784 /sys/devices/virtual/block/loop0/queue/discard_zeroes_data:0 /sys/devices/virtual/block/loop0/queue/max_discard_segments:1 # losetup -d /dev/loop0 # [update util-linux] # losetup --version losetup from util-linux 2.37 # rmmod loop # losetup --find --show disk.img /dev/loop0 # grep '' /sys/devices/virtual/block/loop0/queue/*discard* /sys/devices/virtual/block/loop0/queue/discard_granularity:0 /sys/devices/virtual/block/loop0/queue/discard_max_bytes:0 /sys/devices/virtual/block/loop0/queue/discard_max_hw_bytes:0 /sys/devices/virtual/block/loop0/queue/discard_zeroes_data:0 /sys/devices/virtual/block/loop0/queue/max_discard_segments:1 With the patch applied: # losetup --version losetup from util-linux 2.37 # rmmod loop # losetup --find --show disk.img /dev/loop0 # grep '' /sys/devices/virtual/block/loop0/queue/*discard* /sys/devices/virtual/block/loop0/queue/discard_granularity:4096 /sys/devices/virtual/block/loop0/queue/discard_max_bytes:4294966784 /sys/devices/virtual/block/loop0/queue/discard_max_hw_bytes:4294966784 /sys/devices/virtual/block/loop0/queue/discard_zeroes_data:0 /sys/devices/virtual/block/loop0/queue/max_discard_segments:1 [1] https://github.com/karelzak/util-linux/pull/1152 drivers/block/loop.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 76e12f3482a9..ec957f6d8a49 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1168,6 +1168,8 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, if (partscan) lo->lo_disk->flags &= ~GENHD_FL_NO_PART_SCAN; + loop_config_discard(lo); + /* Grab the block_device to prevent its destruction after we * put /dev/loopXX inode. Later in __loop_clr_fd() we bdput(bdev). */ base-commit: 70585216fe7730d9fb5453d3e2804e149d0fe201 -- 2.32.0