All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huaisheng Ye <yehs2007@zoho.com>
To: dan.j.williams@intel.com
Cc: linux-nvdimm@lists.01.org, chengnt@lenovo.com, jack@suse.com,
	linux-kernel@vger.kernel.org, willy@infradead.org,
	linux-ext4@vger.kernel.org
Subject: [PATCH 3/3] fs/ext2/inode: Optimize the condition for iomap_begin
Date: Sun,  1 Jul 2018 14:18:48 +0800	[thread overview]
Message-ID: <20180701061848.7036-3-yehs2007@zoho.com> (raw)
In-Reply-To: <20180701061848.7036-1-yehs2007@zoho.com>

From: Huaisheng Ye <yehs1@lenovo.com>

If ext2_get_blocks returns negative result, ext2_iomap_begin
will return for error case.
Adjust the judging condition of ret value will be useful for
code simplification.

Signed-off-by: Huaisheng Ye <yehs1@lenovo.com>
---
 fs/ext2/inode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index ca211bd..9b1004d 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -819,15 +819,15 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 	iomap->offset = (loff_t)first_block << blkbits;
 	iomap->dax_dev = sbi->s_daxdev;
 
-	if (ret == 0) {
-		iomap->type = IOMAP_HOLE;
-		iomap->addr = IOMAP_NULL_ADDR;
-		iomap->length = 1 << blkbits;
-	} else {
+	if (ret) {
 		iomap->type = IOMAP_MAPPED;
 		iomap->addr = (u64)bno << blkbits;
 		iomap->length = (u64)ret << blkbits;
 		iomap->flags |= IOMAP_F_MERGED;
+	} else {
+		iomap->type = IOMAP_HOLE;
+		iomap->addr = IOMAP_NULL_ADDR;
+		iomap->length = 1 << blkbits;
 	}
 
 	if (new)
-- 
1.8.3.1


_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

WARNING: multiple messages have this Message-ID (diff)
From: Huaisheng Ye <yehs2007@zoho.com>
To: dan.j.williams@intel.com
Cc: dave.jiang@intel.com, willy@infradead.org,
	ross.zwisler@linux.intel.com, vishal.l.verma@intel.com,
	jack@suse.com, chengnt@lenovo.com, linux-nvdimm@lists.01.org,
	linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org,
	Huaisheng Ye <yehs1@lenovo.com>
Subject: [PATCH 3/3] fs/ext2/inode: Optimize the condition for iomap_begin
Date: Sun,  1 Jul 2018 14:18:48 +0800	[thread overview]
Message-ID: <20180701061848.7036-3-yehs2007@zoho.com> (raw)
In-Reply-To: <20180701061848.7036-1-yehs2007@zoho.com>

From: Huaisheng Ye <yehs1@lenovo.com>

If ext2_get_blocks returns negative result, ext2_iomap_begin
will return for error case.
Adjust the judging condition of ret value will be useful for
code simplification.

Signed-off-by: Huaisheng Ye <yehs1@lenovo.com>
---
 fs/ext2/inode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index ca211bd..9b1004d 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -819,15 +819,15 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 	iomap->offset = (loff_t)first_block << blkbits;
 	iomap->dax_dev = sbi->s_daxdev;
 
-	if (ret == 0) {
-		iomap->type = IOMAP_HOLE;
-		iomap->addr = IOMAP_NULL_ADDR;
-		iomap->length = 1 << blkbits;
-	} else {
+	if (ret) {
 		iomap->type = IOMAP_MAPPED;
 		iomap->addr = (u64)bno << blkbits;
 		iomap->length = (u64)ret << blkbits;
 		iomap->flags |= IOMAP_F_MERGED;
+	} else {
+		iomap->type = IOMAP_HOLE;
+		iomap->addr = IOMAP_NULL_ADDR;
+		iomap->length = 1 << blkbits;
 	}
 
 	if (new)
-- 
1.8.3.1



WARNING: multiple messages have this Message-ID (diff)
From: Huaisheng Ye <yehs2007-ytc+IHgoah0@public.gmane.org>
To: dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Cc: linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org,
	chengnt-6jq1YtArVR3QT0dZR+AlfA@public.gmane.org,
	jack-IBi9RG/b67k@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	willy-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 3/3] fs/ext2/inode: Optimize the condition for iomap_begin
Date: Sun,  1 Jul 2018 14:18:48 +0800	[thread overview]
Message-ID: <20180701061848.7036-3-yehs2007@zoho.com> (raw)
In-Reply-To: <20180701061848.7036-1-yehs2007-ytc+IHgoah0@public.gmane.org>

From: Huaisheng Ye <yehs1-6jq1YtArVR3QT0dZR+AlfA@public.gmane.org>

If ext2_get_blocks returns negative result, ext2_iomap_begin
will return for error case.
Adjust the judging condition of ret value will be useful for
code simplification.

Signed-off-by: Huaisheng Ye <yehs1-6jq1YtArVR3QT0dZR+AlfA@public.gmane.org>
---
 fs/ext2/inode.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index ca211bd..9b1004d 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -819,15 +819,15 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 	iomap->offset = (loff_t)first_block << blkbits;
 	iomap->dax_dev = sbi->s_daxdev;
 
-	if (ret == 0) {
-		iomap->type = IOMAP_HOLE;
-		iomap->addr = IOMAP_NULL_ADDR;
-		iomap->length = 1 << blkbits;
-	} else {
+	if (ret) {
 		iomap->type = IOMAP_MAPPED;
 		iomap->addr = (u64)bno << blkbits;
 		iomap->length = (u64)ret << blkbits;
 		iomap->flags |= IOMAP_F_MERGED;
+	} else {
+		iomap->type = IOMAP_HOLE;
+		iomap->addr = IOMAP_NULL_ADDR;
+		iomap->length = 1 << blkbits;
 	}
 
 	if (new)
-- 
1.8.3.1

  parent reply	other threads:[~2018-07-01  6:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-01  6:18 [PATCH 1/3] drivers/dax/super: Add annotation for ops in struct dax_device Huaisheng Ye
2018-07-01  6:18 ` Huaisheng Ye
2018-07-01  6:18 ` Huaisheng Ye
2018-07-01  6:18 ` [PATCH 2/3] fs/ext2/inode: Fix a type cast error for fsdax Huaisheng Ye
2018-07-01  6:18   ` Huaisheng Ye
2018-07-01  6:18   ` Huaisheng Ye
2018-07-01 19:26   ` Al Viro
2018-07-01 19:26     ` Al Viro
2018-07-01 19:26     ` Al Viro
2018-07-02  6:23     ` Huaisheng Ye
2018-07-02  6:23       ` Huaisheng Ye
2018-07-02  6:23       ` Huaisheng Ye
2018-07-02  7:55       ` Jan Kara
2018-07-02  7:55         ` Jan Kara
2018-07-02  7:55         ` Jan Kara
2018-07-01  6:18 ` Huaisheng Ye [this message]
2018-07-01  6:18   ` [PATCH 3/3] fs/ext2/inode: Optimize the condition for iomap_begin Huaisheng Ye
2018-07-01  6:18   ` Huaisheng Ye
2018-07-02  7:57   ` Jan Kara
2018-07-02  7:57     ` Jan Kara
2018-07-02  7:57     ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180701061848.7036-3-yehs2007@zoho.com \
    --to=yehs2007@zoho.com \
    --cc=chengnt@lenovo.com \
    --cc=dan.j.williams@intel.com \
    --cc=jack@suse.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.