[PATCH 4/6] Xarray: skip unneeded xas_store() and xas_clear_mark() in __xa_alloc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If xas_find_marked() failed, there is no need to call xas_store() and
xas_clear_mark(). Just call xas_store() and xas_clear_mark() if
xas_find_marked() succeed.

Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
---
 lib/xarray.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/xarray.c b/lib/xarray.c
index 3fac3f2cea9d..012d0ef5e847 100644
--- a/lib/xarray.c
+++ b/lib/xarray.c
@@ -1860,10 +1860,11 @@ int __xa_alloc(struct xarray *xa, u32 *id, void *entry,
 		xas_find_marked(&xas, limit.max, XA_FREE_MARK);
 		if (xas.xa_node == XAS_RESTART)
 			xas_set_err(&xas, -EBUSY);
-		else
+		else {
 			*id = xas.xa_index;
-		xas_store(&xas, entry);
-		xas_clear_mark(&xas, XA_FREE_MARK);
+			xas_store(&xas, entry);
+			xas_clear_mark(&xas, XA_FREE_MARK);
+		}
 	} while (__xas_nomem(&xas, gfp));
 
 	return xas_error(&xas);
-- 
2.30.0





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux