Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3642311pxf; Mon, 15 Mar 2021 14:45:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx51RXHysHQ3Gv4yx3Qj1coSy17Q3DN4j+C7ayhpCXGhf8xNgSzOvNfnOsNdPcke2tzLzV X-Received: by 2002:a17:906:4d96:: with SMTP id s22mr25991588eju.189.1615844718783; Mon, 15 Mar 2021 14:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615844718; cv=none; d=google.com; s=arc-20160816; b=e3wC5CRjq/4GyZ36N2eYYXFX1UPTOFIugeExYzCuLHxWOTIEhFkVIej6qlIBxx1wm8 7N85dkJCq6tqtEFnMmwDXkxQJC8M+EzzsixML2kFyqoFWdwLqMPvN/OX/nzETPlI04YO ClahUZjgC1dfeedJkIXErWYTJK7YwNAq8ltvyp/7kRzVz5doGWEJQinRt+iS6yxGT1Qs Ugt/E+V30w9K9VFXnr5CXthi/u7GRmwf/Ks8qkhnetosMzl+/3c597pxpYVEiMksvyx3 6wB+Kr2q5EW4nXyZEG1oeMOEDrbTHwsq5RMUCNNbASubLK0wX689hGydPEVCChFrVnGu a9xg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DV40QsbLmfrHazcRS7XkP3bcaAXUsBsn36zxNtb6dP8=; b=DS6cw6ge+gdLdDLw7Or1nQWSTCvci+KcB8jRdOsXxpG7UAeCp32Txi9ZMEuCy+hDqR SbR0Pm7hrcp+yU/G/Em8rnYlbUAlN66XR21U7pV5zuW9EZreVp8R6aW3zG224HOo3JNG 3lvzhSHNMjog715mEtrD6wvTW64dUtiYi27wfoyghBDDX0wiWxiDboqLze1lG8skPL3F Bzhg7yp1bRlCrxoRDlXnJu+qm8ijP9Wbqg5khqYTRw8TdKSwMMN5gsuVtPQSdor6hLQ+ T8TlaBUS0L8n1vltd9PdIs8vyxGlcrFEi3y/cCPdq82vUy+Y657Y6O8Au2hVTCKfxZRo uInQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a8si11832103edq.601.2021.03.15.14.44.56; Mon, 15 Mar 2021 14:45:18 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234054AbhCOUEM (ORCPT + 99 others); Mon, 15 Mar 2021 16:04:12 -0400 Received: from mail-ej1-f53.google.com ([209.85.218.53]:36847 "EHLO mail-ej1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233925AbhCOUDs (ORCPT ); Mon, 15 Mar 2021 16:03:48 -0400 Received: by mail-ej1-f53.google.com with SMTP id e19so68488837ejt.3; Mon, 15 Mar 2021 13:03:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DV40QsbLmfrHazcRS7XkP3bcaAXUsBsn36zxNtb6dP8=; b=W/7sucFbvFG462CxXMsQbGlcfthxTZTvUHcC+eZbyKe8XG6M4RsEUPYA5pgtxTA+lx 5LDaL6RRALZ5RglKs3qWWasrTOBK3XejloHhcalHbQtP7M8Lh0O4LwzONSvF+GPxDFBY iRxGXiYNr0Z1+qX+97wpYRp4cTqiFax1DNL2NRkZj04+M+mMGHYNIGfoXnWjuVaTVV+q wR11dQhpg3C/9vvirwHyjI2JNFgaD5BfSbouJBSGGf2TVe0z/wWedI45dVRv7XLTS5eX QgOitvNNkB0xoyYgGD2dfTVObiStCSWBtOnrfc9KE6Kh7q7VYRLUwAC3yWGQGGIs0Qqg MKGQ== X-Gm-Message-State: AOAM5316eqv9aC4a17sQw27RzODO2MT3+4YvvemZlE1J6Jswzu6u7FUl 5bgi5Ns1asyiStzh28INbYNff7T5rhSTfg== X-Received: by 2002:a17:906:be9:: with SMTP id z9mr25347682ejg.35.1615838627191; Mon, 15 Mar 2021 13:03:47 -0700 (PDT) Received: from msft-t490s.teknoraver.net (net-188-216-41-250.cust.vodafonedsl.it. [188.216.41.250]) by smtp.gmail.com with ESMTPSA id x21sm8551210eds.53.2021.03.15.13.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 13:03:46 -0700 (PDT) From: Matteo Croce To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Lennart Poettering , Luca Boccassi , Jens Axboe , Alexander Viro , Damien Le Moal , Tejun Heo , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , Niklas Cassel , Johannes Thumshirn , Hannes Reinecke Subject: [PATCH -next 5/5] loop: increment sequence number Date: Mon, 15 Mar 2021 21:02:42 +0100 Message-Id: <20210315200242.67355-6-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315200242.67355-1-mcroce@linux.microsoft.com> References: <20210315200242.67355-1-mcroce@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matteo Croce On a very loaded system, if there are many events queued up from multiple attach/detach cycles, it's impossible to match them up with the LOOP_CONFIGURE or LOOP_SET_FD call, since we don't know where the position of our own association in the queue is[1]. Not even an empty uevent queue is a reliable indication that we already received the uevent we were waiting for, since with multi-partition block devices each partition's event is queued asynchronously and might be delivered later. Increment the disk sequence number when setting or changing the backing file, so the userspace knows which backing file generated the event. [1] https://github.com/systemd/systemd/issues/17469#issuecomment-762919781 Signed-off-by: Matteo Croce --- drivers/block/loop.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index a370cde3ddd4..1541ccff81f9 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -734,6 +734,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, goto out_err; /* and ... switch */ + inc_diskseq(lo->lo_disk); blk_mq_freeze_queue(lo->lo_queue); mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask); lo->lo_backing_file = file; @@ -1122,6 +1123,8 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, if (error) goto out_unlock; + inc_diskseq(lo->lo_disk); + if (!(file->f_mode & FMODE_WRITE) || !(mode & FMODE_WRITE) || !file->f_op->write_iter) lo->lo_flags |= LO_FLAGS_READ_ONLY; -- 2.30.2