Skip to contentSkip to conversation

gfs2: Fix recovery slot bumping

PATCH New Andreas Gruenbacher 2 participants 2 messages Aug 26, 2019 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Fix recovery slot bumping

Get rid of the assumption that the number of slots can at most increase by RECOVER_SIZE_INC (16) in set_recover_size.

---
 fs/gfs2/lock_dlm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/gfs2/lock_dlm.c +4 -4
index 4361804646d8..2bc7a334aa0a 100644
@@ -1035,12 +1035,12 @@ static int set_recover_size(struct gfs2_sbd *sdp, struct dlm_slot *slots,
 	}
 
 	old_size = ls->ls_recover_size;
-
-	if (old_size >= max_jid + 1)
+	new_size = old_size;
+	while (new_size < max_jid + 1)
+		new_size += RECOVER_SIZE_INC;
+	if (old_size == new_size)
 		return 0;
 
-	new_size = old_size + RECOVER_SIZE_INC;
-
 	submit = kcalloc(new_size, sizeof(uint32_t), GFP_NOFS);
 	result = kcalloc(new_size, sizeof(uint32_t), GFP_NOFS);
 	if (!submit || !result) {
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 gfs2: Fix recovery slot bumping

----- Original Message -----

Quoted 29 lines

Get rid of the assumption that the number of slots can at most increase by RECOVER_SIZE_INC (16) in set_recover_size.

---
 fs/gfs2/lock_dlm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/gfs2/lock_dlm.c +4 -4
index 4361804646d8..2bc7a334aa0a 100644
@@ -1035,12 +1035,12 @@ static int set_recover_size(struct gfs2_sbd *sdp,
 struct dlm_slot *slots,
 	}
 
 	old_size = ls->ls_recover_size;
-
-	if (old_size >= max_jid + 1)
+	new_size = old_size;
+	while (new_size < max_jid + 1)
+		new_size += RECOVER_SIZE_INC;
+	if (old_size == new_size)
 		return 0;
 
-	new_size = old_size + RECOVER_SIZE_INC;
-
 	submit = kcalloc(new_size, sizeof(uint32_t), GFP_NOFS);
 	result = kcalloc(new_size, sizeof(uint32_t), GFP_NOFS);
Quoted 3 lines

if (!submit || !result) {
--
2.20.1

Yes, that works, although I think it's more clear to say:
+ if (new_size == old_size)
than:
+ if (old_size == new_size)
IOW, it just sounds better. But whatever. It works either way.

Bob