From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2452AC7EE33 for ; Tue, 6 Jun 2023 08:25:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236507AbjFFIZO convert rfc822-to-8bit (ORCPT ); Tue, 6 Jun 2023 04:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236098AbjFFIYs (ORCPT ); Tue, 6 Jun 2023 04:24:48 -0400 Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AC10E62; Tue, 6 Jun 2023 01:24:41 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id A2DC56081100; Tue, 6 Jun 2023 10:24:39 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id siZzZpJorNJf; Tue, 6 Jun 2023 10:24:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 34240616B2CF; Tue, 6 Jun 2023 10:24:39 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id YeogKuuY1hxw; Tue, 6 Jun 2023 10:24:39 +0200 (CEST) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lithops.sigma-star.at (Postfix) with ESMTP id E97466081100; Tue, 6 Jun 2023 10:24:38 +0200 (CEST) Date: Tue, 6 Jun 2023 10:24:38 +0200 (CEST) From: Richard Weinberger To: hch Cc: Jens Axboe , Josef Bacik , "Md. Haris Iqbal" , Jack Wang , Phillip Potter , Coly Li , Miquel Raynal , Vignesh Raghavendra , "Martin K. Petersen" , Chris Mason , David Sterba , Al Viro , Christian Brauner , "Rafael J. Wysocki" , Pavel Machek , dm-devel , linux-block , linux-um , linux-scsi , linux-bcache , linux-mtd , linux-nvme , linux-btrfs , linux-f2fs-devel , linux-nilfs , linux-fsdevel , linux-pm Message-ID: <318049918.3687133.1686039878761.JavaMail.zimbra@nod.at> In-Reply-To: <20230606073950.225178-24-hch@lst.de> References: <20230606073950.225178-1-hch@lst.de> <20230606073950.225178-24-hch@lst.de> Subject: Re: [PATCH 23/31] mtd: block: use a simple bool to track open for write MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [195.201.40.130] X-Mailer: Zimbra 8.8.12_GA_3807 (ZimbraWebClient - FF97 (Linux)/8.8.12_GA_3809) Thread-Topic: block: use a simple bool to track open for write Thread-Index: X/xlpyhSf8bloXE5HNEoh3ox5Q1J9Q== Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org ----- Ursprüngliche Mail ----- > Von: "hch" > Instead of propagating the fmode_t, just use a bool to track if a mtd > block device was opened for writing. > > Signed-off-by: Christoph Hellwig > --- > drivers/mtd/mtd_blkdevs.c | 2 +- > drivers/mtd/mtdblock.c | 2 +- > include/linux/mtd/blktrans.h | 2 +- > 3 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c > index f0bb09fde95e3a..bd0b7545364349 100644 > --- a/drivers/mtd/mtd_blkdevs.c > +++ b/drivers/mtd/mtd_blkdevs.c > @@ -208,7 +208,7 @@ static int blktrans_open(struct gendisk *disk, fmode_t mode) > ret = __get_mtd_device(dev->mtd); > if (ret) > goto error_release; > - dev->file_mode = mode; > + dev->writable = mode & FMODE_WRITE; > > unlock: > dev->open++; > diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c > index a0a1194dc1d902..fa476fb4dffb6c 100644 > --- a/drivers/mtd/mtdblock.c > +++ b/drivers/mtd/mtdblock.c > @@ -294,7 +294,7 @@ static void mtdblock_release(struct mtd_blktrans_dev *mbd) > * It was the last usage. Free the cache, but only sync if > * opened for writing. > */ > - if (mbd->file_mode & FMODE_WRITE) > + if (mbd->writable) > mtd_sync(mbd->mtd); > vfree(mtdblk->cache_data); > } > diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h > index 15cc9b95e32b52..6e471436bba556 100644 > --- a/include/linux/mtd/blktrans.h > +++ b/include/linux/mtd/blktrans.h > @@ -34,7 +34,7 @@ struct mtd_blktrans_dev { > struct blk_mq_tag_set *tag_set; > spinlock_t queue_lock; > void *priv; > - fmode_t file_mode; > + bool writable; > }; Acked-by: Richard Weinberger Thanks, //richard