Commit d293d3af authored by Takashi Iwai's avatar Takashi Iwai Committed by Linus Torvalds

ocfs2: use scnprintf() for avoiding potential buffer overflow

Since snprintf() returns the would-be-output size instead of the actual
output size, the succeeding calls may go beyond the given buffer limit.
Fix it by replacing with scnprintf().
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: Jun Piao <piaojun@huawei.com>
Link: http://lkml.kernel.org/r/20200311093516.25300-1-tiwai@suse.deSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0434c9f4
...@@ -1307,7 +1307,7 @@ static int o2hb_debug_open(struct inode *inode, struct file *file) ...@@ -1307,7 +1307,7 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)
case O2HB_DB_TYPE_REGION_NUMBER: case O2HB_DB_TYPE_REGION_NUMBER:
reg = (struct o2hb_region *)db->db_data; reg = (struct o2hb_region *)db->db_data;
out += snprintf(buf + out, PAGE_SIZE - out, "%d\n", out += scnprintf(buf + out, PAGE_SIZE - out, "%d\n",
reg->hr_region_num); reg->hr_region_num);
goto done; goto done;
...@@ -1317,12 +1317,12 @@ static int o2hb_debug_open(struct inode *inode, struct file *file) ...@@ -1317,12 +1317,12 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)
/* If 0, it has never been set before */ /* If 0, it has never been set before */
if (lts) if (lts)
lts = jiffies_to_msecs(jiffies - lts); lts = jiffies_to_msecs(jiffies - lts);
out += snprintf(buf + out, PAGE_SIZE - out, "%lu\n", lts); out += scnprintf(buf + out, PAGE_SIZE - out, "%lu\n", lts);
goto done; goto done;
case O2HB_DB_TYPE_REGION_PINNED: case O2HB_DB_TYPE_REGION_PINNED:
reg = (struct o2hb_region *)db->db_data; reg = (struct o2hb_region *)db->db_data;
out += snprintf(buf + out, PAGE_SIZE - out, "%u\n", out += scnprintf(buf + out, PAGE_SIZE - out, "%u\n",
!!reg->hr_item_pinned); !!reg->hr_item_pinned);
goto done; goto done;
...@@ -1331,8 +1331,8 @@ static int o2hb_debug_open(struct inode *inode, struct file *file) ...@@ -1331,8 +1331,8 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)
} }
while ((i = find_next_bit(map, db->db_len, i + 1)) < db->db_len) while ((i = find_next_bit(map, db->db_len, i + 1)) < db->db_len)
out += snprintf(buf + out, PAGE_SIZE - out, "%d ", i); out += scnprintf(buf + out, PAGE_SIZE - out, "%d ", i);
out += snprintf(buf + out, PAGE_SIZE - out, "\n"); out += scnprintf(buf + out, PAGE_SIZE - out, "\n");
done: done:
i_size_write(inode, out); i_size_write(inode, out);
......
...@@ -443,8 +443,8 @@ static int o2net_fill_bitmap(char *buf, int len) ...@@ -443,8 +443,8 @@ static int o2net_fill_bitmap(char *buf, int len)
o2net_fill_node_map(map, sizeof(map)); o2net_fill_node_map(map, sizeof(map));
while ((i = find_next_bit(map, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) while ((i = find_next_bit(map, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES)
out += snprintf(buf + out, PAGE_SIZE - out, "%d ", i); out += scnprintf(buf + out, PAGE_SIZE - out, "%d ", i);
out += snprintf(buf + out, PAGE_SIZE - out, "\n"); out += scnprintf(buf + out, PAGE_SIZE - out, "\n");
return out; return out;
} }
......
...@@ -244,11 +244,11 @@ static int stringify_lockname(const char *lockname, int locklen, char *buf, ...@@ -244,11 +244,11 @@ static int stringify_lockname(const char *lockname, int locklen, char *buf,
memcpy((__be64 *)&inode_blkno_be, memcpy((__be64 *)&inode_blkno_be,
(char *)&lockname[OCFS2_DENTRY_LOCK_INO_START], (char *)&lockname[OCFS2_DENTRY_LOCK_INO_START],
sizeof(__be64)); sizeof(__be64));
out += snprintf(buf + out, len - out, "%.*s%08x", out += scnprintf(buf + out, len - out, "%.*s%08x",
OCFS2_DENTRY_LOCK_INO_START - 1, lockname, OCFS2_DENTRY_LOCK_INO_START - 1, lockname,
(unsigned int)be64_to_cpu(inode_blkno_be)); (unsigned int)be64_to_cpu(inode_blkno_be));
} else } else
out += snprintf(buf + out, len - out, "%.*s", out += scnprintf(buf + out, len - out, "%.*s",
locklen, lockname); locklen, lockname);
return out; return out;
} }
...@@ -260,7 +260,7 @@ static int stringify_nodemap(unsigned long *nodemap, int maxnodes, ...@@ -260,7 +260,7 @@ static int stringify_nodemap(unsigned long *nodemap, int maxnodes,
int i = -1; int i = -1;
while ((i = find_next_bit(nodemap, maxnodes, i + 1)) < maxnodes) while ((i = find_next_bit(nodemap, maxnodes, i + 1)) < maxnodes)
out += snprintf(buf + out, len - out, "%d ", i); out += scnprintf(buf + out, len - out, "%d ", i);
return out; return out;
} }
...@@ -278,34 +278,34 @@ static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len) ...@@ -278,34 +278,34 @@ static int dump_mle(struct dlm_master_list_entry *mle, char *buf, int len)
mle_type = "MIG"; mle_type = "MIG";
out += stringify_lockname(mle->mname, mle->mnamelen, buf + out, len - out); out += stringify_lockname(mle->mname, mle->mnamelen, buf + out, len - out);
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n", "\t%3s\tmas=%3u\tnew=%3u\tevt=%1d\tuse=%1d\tref=%3d\n",
mle_type, mle->master, mle->new_master, mle_type, mle->master, mle->new_master,
!list_empty(&mle->hb_events), !list_empty(&mle->hb_events),
!!mle->inuse, !!mle->inuse,
kref_read(&mle->mle_refs)); kref_read(&mle->mle_refs));
out += snprintf(buf + out, len - out, "Maybe="); out += scnprintf(buf + out, len - out, "Maybe=");
out += stringify_nodemap(mle->maybe_map, O2NM_MAX_NODES, out += stringify_nodemap(mle->maybe_map, O2NM_MAX_NODES,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
out += snprintf(buf + out, len - out, "Vote="); out += scnprintf(buf + out, len - out, "Vote=");
out += stringify_nodemap(mle->vote_map, O2NM_MAX_NODES, out += stringify_nodemap(mle->vote_map, O2NM_MAX_NODES,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
out += snprintf(buf + out, len - out, "Response="); out += scnprintf(buf + out, len - out, "Response=");
out += stringify_nodemap(mle->response_map, O2NM_MAX_NODES, out += stringify_nodemap(mle->response_map, O2NM_MAX_NODES,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
out += snprintf(buf + out, len - out, "Node="); out += scnprintf(buf + out, len - out, "Node=");
out += stringify_nodemap(mle->node_map, O2NM_MAX_NODES, out += stringify_nodemap(mle->node_map, O2NM_MAX_NODES,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
return out; return out;
} }
...@@ -353,7 +353,7 @@ static int debug_purgelist_print(struct dlm_ctxt *dlm, char *buf, int len) ...@@ -353,7 +353,7 @@ static int debug_purgelist_print(struct dlm_ctxt *dlm, char *buf, int len)
int out = 0; int out = 0;
unsigned long total = 0; unsigned long total = 0;
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Dumping Purgelist for Domain: %s\n", dlm->name); "Dumping Purgelist for Domain: %s\n", dlm->name);
spin_lock(&dlm->spinlock); spin_lock(&dlm->spinlock);
...@@ -365,13 +365,13 @@ static int debug_purgelist_print(struct dlm_ctxt *dlm, char *buf, int len) ...@@ -365,13 +365,13 @@ static int debug_purgelist_print(struct dlm_ctxt *dlm, char *buf, int len)
out += stringify_lockname(res->lockname.name, out += stringify_lockname(res->lockname.name,
res->lockname.len, res->lockname.len,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\t%ld\n", out += scnprintf(buf + out, len - out, "\t%ld\n",
(jiffies - res->last_used)/HZ); (jiffies - res->last_used)/HZ);
spin_unlock(&res->spinlock); spin_unlock(&res->spinlock);
} }
spin_unlock(&dlm->spinlock); spin_unlock(&dlm->spinlock);
out += snprintf(buf + out, len - out, "Total on list: %lu\n", total); out += scnprintf(buf + out, len - out, "Total on list: %lu\n", total);
return out; return out;
} }
...@@ -410,7 +410,7 @@ static int debug_mle_print(struct dlm_ctxt *dlm, char *buf, int len) ...@@ -410,7 +410,7 @@ static int debug_mle_print(struct dlm_ctxt *dlm, char *buf, int len)
int i, out = 0; int i, out = 0;
unsigned long total = 0, longest = 0, bucket_count = 0; unsigned long total = 0, longest = 0, bucket_count = 0;
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Dumping MLEs for Domain: %s\n", dlm->name); "Dumping MLEs for Domain: %s\n", dlm->name);
spin_lock(&dlm->master_lock); spin_lock(&dlm->master_lock);
...@@ -428,7 +428,7 @@ static int debug_mle_print(struct dlm_ctxt *dlm, char *buf, int len) ...@@ -428,7 +428,7 @@ static int debug_mle_print(struct dlm_ctxt *dlm, char *buf, int len)
} }
spin_unlock(&dlm->master_lock); spin_unlock(&dlm->master_lock);
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Total: %lu, Longest: %lu\n", total, longest); "Total: %lu, Longest: %lu\n", total, longest);
return out; return out;
} }
...@@ -467,7 +467,7 @@ static int dump_lock(struct dlm_lock *lock, int list_type, char *buf, int len) ...@@ -467,7 +467,7 @@ static int dump_lock(struct dlm_lock *lock, int list_type, char *buf, int len)
#define DEBUG_LOCK_VERSION 1 #define DEBUG_LOCK_VERSION 1
spin_lock(&lock->spinlock); spin_lock(&lock->spinlock);
out = snprintf(buf, len, "LOCK:%d,%d,%d,%d,%d,%d:%lld,%d,%d,%d,%d,%d," out = scnprintf(buf, len, "LOCK:%d,%d,%d,%d,%d,%d:%lld,%d,%d,%d,%d,%d,"
"%d,%d,%d,%d\n", "%d,%d,%d,%d\n",
DEBUG_LOCK_VERSION, DEBUG_LOCK_VERSION,
list_type, lock->ml.type, lock->ml.convert_type, list_type, lock->ml.type, lock->ml.convert_type,
...@@ -491,13 +491,13 @@ static int dump_lockres(struct dlm_lock_resource *res, char *buf, int len) ...@@ -491,13 +491,13 @@ static int dump_lockres(struct dlm_lock_resource *res, char *buf, int len)
int i; int i;
int out = 0; int out = 0;
out += snprintf(buf + out, len - out, "NAME:"); out += scnprintf(buf + out, len - out, "NAME:");
out += stringify_lockname(res->lockname.name, res->lockname.len, out += stringify_lockname(res->lockname.name, res->lockname.len,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
#define DEBUG_LRES_VERSION 1 #define DEBUG_LRES_VERSION 1
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"LRES:%d,%d,%d,%ld,%d,%d,%d,%d,%d,%d,%d\n", "LRES:%d,%d,%d,%ld,%d,%d,%d,%d,%d,%d,%d\n",
DEBUG_LRES_VERSION, DEBUG_LRES_VERSION,
res->owner, res->state, res->last_used, res->owner, res->state, res->last_used,
...@@ -509,17 +509,17 @@ static int dump_lockres(struct dlm_lock_resource *res, char *buf, int len) ...@@ -509,17 +509,17 @@ static int dump_lockres(struct dlm_lock_resource *res, char *buf, int len)
kref_read(&res->refs)); kref_read(&res->refs));
/* refmap */ /* refmap */
out += snprintf(buf + out, len - out, "RMAP:"); out += scnprintf(buf + out, len - out, "RMAP:");
out += stringify_nodemap(res->refmap, O2NM_MAX_NODES, out += stringify_nodemap(res->refmap, O2NM_MAX_NODES,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
/* lvb */ /* lvb */
out += snprintf(buf + out, len - out, "LVBX:"); out += scnprintf(buf + out, len - out, "LVBX:");
for (i = 0; i < DLM_LVB_LEN; i++) for (i = 0; i < DLM_LVB_LEN; i++)
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%02x", (unsigned char)res->lvb[i]); "%02x", (unsigned char)res->lvb[i]);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
/* granted */ /* granted */
list_for_each_entry(lock, &res->granted, list) list_for_each_entry(lock, &res->granted, list)
...@@ -533,7 +533,7 @@ static int dump_lockres(struct dlm_lock_resource *res, char *buf, int len) ...@@ -533,7 +533,7 @@ static int dump_lockres(struct dlm_lock_resource *res, char *buf, int len)
list_for_each_entry(lock, &res->blocked, list) list_for_each_entry(lock, &res->blocked, list)
out += dump_lock(lock, 2, buf + out, len - out); out += dump_lock(lock, 2, buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
return out; return out;
} }
...@@ -683,41 +683,41 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len) ...@@ -683,41 +683,41 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len)
} }
/* Domain: xxxxxxxxxx Key: 0xdfbac769 */ /* Domain: xxxxxxxxxx Key: 0xdfbac769 */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Domain: %s Key: 0x%08x Protocol: %d.%d\n", "Domain: %s Key: 0x%08x Protocol: %d.%d\n",
dlm->name, dlm->key, dlm->dlm_locking_proto.pv_major, dlm->name, dlm->key, dlm->dlm_locking_proto.pv_major,
dlm->dlm_locking_proto.pv_minor); dlm->dlm_locking_proto.pv_minor);
/* Thread Pid: xxx Node: xxx State: xxxxx */ /* Thread Pid: xxx Node: xxx State: xxxxx */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Thread Pid: %d Node: %d State: %s\n", "Thread Pid: %d Node: %d State: %s\n",
task_pid_nr(dlm->dlm_thread_task), dlm->node_num, state); task_pid_nr(dlm->dlm_thread_task), dlm->node_num, state);
/* Number of Joins: xxx Joining Node: xxx */ /* Number of Joins: xxx Joining Node: xxx */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Number of Joins: %d Joining Node: %d\n", "Number of Joins: %d Joining Node: %d\n",
dlm->num_joins, dlm->joining_node); dlm->num_joins, dlm->joining_node);
/* Domain Map: xx xx xx */ /* Domain Map: xx xx xx */
out += snprintf(buf + out, len - out, "Domain Map: "); out += scnprintf(buf + out, len - out, "Domain Map: ");
out += stringify_nodemap(dlm->domain_map, O2NM_MAX_NODES, out += stringify_nodemap(dlm->domain_map, O2NM_MAX_NODES,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
/* Exit Domain Map: xx xx xx */ /* Exit Domain Map: xx xx xx */
out += snprintf(buf + out, len - out, "Exit Domain Map: "); out += scnprintf(buf + out, len - out, "Exit Domain Map: ");
out += stringify_nodemap(dlm->exit_domain_map, O2NM_MAX_NODES, out += stringify_nodemap(dlm->exit_domain_map, O2NM_MAX_NODES,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
/* Live Map: xx xx xx */ /* Live Map: xx xx xx */
out += snprintf(buf + out, len - out, "Live Map: "); out += scnprintf(buf + out, len - out, "Live Map: ");
out += stringify_nodemap(dlm->live_nodes_map, O2NM_MAX_NODES, out += stringify_nodemap(dlm->live_nodes_map, O2NM_MAX_NODES,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
/* Lock Resources: xxx (xxx) */ /* Lock Resources: xxx (xxx) */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Lock Resources: %d (%d)\n", "Lock Resources: %d (%d)\n",
atomic_read(&dlm->res_cur_count), atomic_read(&dlm->res_cur_count),
atomic_read(&dlm->res_tot_count)); atomic_read(&dlm->res_tot_count));
...@@ -729,29 +729,29 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len) ...@@ -729,29 +729,29 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len)
cur_mles += atomic_read(&dlm->mle_cur_count[i]); cur_mles += atomic_read(&dlm->mle_cur_count[i]);
/* MLEs: xxx (xxx) */ /* MLEs: xxx (xxx) */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"MLEs: %d (%d)\n", cur_mles, tot_mles); "MLEs: %d (%d)\n", cur_mles, tot_mles);
/* Blocking: xxx (xxx) */ /* Blocking: xxx (xxx) */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
" Blocking: %d (%d)\n", " Blocking: %d (%d)\n",
atomic_read(&dlm->mle_cur_count[DLM_MLE_BLOCK]), atomic_read(&dlm->mle_cur_count[DLM_MLE_BLOCK]),
atomic_read(&dlm->mle_tot_count[DLM_MLE_BLOCK])); atomic_read(&dlm->mle_tot_count[DLM_MLE_BLOCK]));
/* Mastery: xxx (xxx) */ /* Mastery: xxx (xxx) */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
" Mastery: %d (%d)\n", " Mastery: %d (%d)\n",
atomic_read(&dlm->mle_cur_count[DLM_MLE_MASTER]), atomic_read(&dlm->mle_cur_count[DLM_MLE_MASTER]),
atomic_read(&dlm->mle_tot_count[DLM_MLE_MASTER])); atomic_read(&dlm->mle_tot_count[DLM_MLE_MASTER]));
/* Migration: xxx (xxx) */ /* Migration: xxx (xxx) */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
" Migration: %d (%d)\n", " Migration: %d (%d)\n",
atomic_read(&dlm->mle_cur_count[DLM_MLE_MIGRATION]), atomic_read(&dlm->mle_cur_count[DLM_MLE_MIGRATION]),
atomic_read(&dlm->mle_tot_count[DLM_MLE_MIGRATION])); atomic_read(&dlm->mle_tot_count[DLM_MLE_MIGRATION]));
/* Lists: Dirty=Empty Purge=InUse PendingASTs=Empty ... */ /* Lists: Dirty=Empty Purge=InUse PendingASTs=Empty ... */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Lists: Dirty=%s Purge=%s PendingASTs=%s " "Lists: Dirty=%s Purge=%s PendingASTs=%s "
"PendingBASTs=%s\n", "PendingBASTs=%s\n",
(list_empty(&dlm->dirty_list) ? "Empty" : "InUse"), (list_empty(&dlm->dirty_list) ? "Empty" : "InUse"),
...@@ -760,12 +760,12 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len) ...@@ -760,12 +760,12 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len)
(list_empty(&dlm->pending_basts) ? "Empty" : "InUse")); (list_empty(&dlm->pending_basts) ? "Empty" : "InUse"));
/* Purge Count: xxx Refs: xxx */ /* Purge Count: xxx Refs: xxx */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Purge Count: %d Refs: %d\n", dlm->purge_count, "Purge Count: %d Refs: %d\n", dlm->purge_count,
kref_read(&dlm->dlm_refs)); kref_read(&dlm->dlm_refs));
/* Dead Node: xxx */ /* Dead Node: xxx */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Dead Node: %d\n", dlm->reco.dead_node); "Dead Node: %d\n", dlm->reco.dead_node);
/* What about DLM_RECO_STATE_FINALIZE? */ /* What about DLM_RECO_STATE_FINALIZE? */
...@@ -775,19 +775,19 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len) ...@@ -775,19 +775,19 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len)
state = "INACTIVE"; state = "INACTIVE";
/* Recovery Pid: xxxx Master: xxx State: xxxx */ /* Recovery Pid: xxxx Master: xxx State: xxxx */
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"Recovery Pid: %d Master: %d State: %s\n", "Recovery Pid: %d Master: %d State: %s\n",
task_pid_nr(dlm->dlm_reco_thread_task), task_pid_nr(dlm->dlm_reco_thread_task),
dlm->reco.new_master, state); dlm->reco.new_master, state);
/* Recovery Map: xx xx */ /* Recovery Map: xx xx */
out += snprintf(buf + out, len - out, "Recovery Map: "); out += scnprintf(buf + out, len - out, "Recovery Map: ");
out += stringify_nodemap(dlm->recovery_map, O2NM_MAX_NODES, out += stringify_nodemap(dlm->recovery_map, O2NM_MAX_NODES,
buf + out, len - out); buf + out, len - out);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
/* Recovery Node State: */ /* Recovery Node State: */
out += snprintf(buf + out, len - out, "Recovery Node State:\n"); out += scnprintf(buf + out, len - out, "Recovery Node State:\n");
list_for_each_entry(node, &dlm->reco.node_data, list) { list_for_each_entry(node, &dlm->reco.node_data, list) {
switch (node->state) { switch (node->state) {
case DLM_RECO_NODE_DATA_INIT: case DLM_RECO_NODE_DATA_INIT:
...@@ -815,7 +815,7 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len) ...@@ -815,7 +815,7 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len)
state = "BAD"; state = "BAD";
break; break;
} }
out += snprintf(buf + out, len - out, "\t%u - %s\n", out += scnprintf(buf + out, len - out, "\t%u - %s\n",
node->node_num, state); node->node_num, state);
} }
......
...@@ -220,31 +220,31 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len) ...@@ -220,31 +220,31 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
int i, out = 0; int i, out = 0;
unsigned long flags; unsigned long flags;
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => Id: %-s Uuid: %-s Gen: 0x%X Label: %-s\n", "%10s => Id: %-s Uuid: %-s Gen: 0x%X Label: %-s\n",
"Device", osb->dev_str, osb->uuid_str, "Device", osb->dev_str, osb->uuid_str,
osb->fs_generation, osb->vol_label); osb->fs_generation, osb->vol_label);
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => State: %d Flags: 0x%lX\n", "Volume", "%10s => State: %d Flags: 0x%lX\n", "Volume",
atomic_read(&osb->vol_state), osb->osb_flags); atomic_read(&osb->vol_state), osb->osb_flags);
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => Block: %lu Cluster: %d\n", "Sizes", "%10s => Block: %lu Cluster: %d\n", "Sizes",
osb->sb->s_blocksize, osb->s_clustersize); osb->sb->s_blocksize, osb->s_clustersize);
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => Compat: 0x%X Incompat: 0x%X " "%10s => Compat: 0x%X Incompat: 0x%X "
"ROcompat: 0x%X\n", "ROcompat: 0x%X\n",
"Features", osb->s_feature_compat, "Features", osb->s_feature_compat,
osb->s_feature_incompat, osb->s_feature_ro_compat); osb->s_feature_incompat, osb->s_feature_ro_compat);
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => Opts: 0x%lX AtimeQuanta: %u\n", "Mount", "%10s => Opts: 0x%lX AtimeQuanta: %u\n", "Mount",
osb->s_mount_opt, osb->s_atime_quantum); osb->s_mount_opt, osb->s_atime_quantum);
if (cconn) { if (cconn) {
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => Stack: %s Name: %*s " "%10s => Stack: %s Name: %*s "
"Version: %d.%d\n", "Cluster", "Version: %d.%d\n", "Cluster",
(*osb->osb_cluster_stack == '\0' ? (*osb->osb_cluster_stack == '\0' ?
...@@ -255,7 +255,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len) ...@@ -255,7 +255,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
} }
spin_lock_irqsave(&osb->dc_task_lock, flags); spin_lock_irqsave(&osb->dc_task_lock, flags);
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => Pid: %d Count: %lu WakeSeq: %lu " "%10s => Pid: %d Count: %lu WakeSeq: %lu "
"WorkSeq: %lu\n", "DownCnvt", "WorkSeq: %lu\n", "DownCnvt",
(osb->dc_task ? task_pid_nr(osb->dc_task) : -1), (osb->dc_task ? task_pid_nr(osb->dc_task) : -1),
...@@ -264,32 +264,32 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len) ...@@ -264,32 +264,32 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
spin_unlock_irqrestore(&osb->dc_task_lock, flags); spin_unlock_irqrestore(&osb->dc_task_lock, flags);
spin_lock(&osb->osb_lock); spin_lock(&osb->osb_lock);
out += snprintf(buf + out, len - out, "%10s => Pid: %d Nodes:", out += scnprintf(buf + out, len - out, "%10s => Pid: %d Nodes:",
"Recovery", "Recovery",
(osb->recovery_thread_task ? (osb->recovery_thread_task ?
task_pid_nr(osb->recovery_thread_task) : -1)); task_pid_nr(osb->recovery_thread_task) : -1));
if (rm->rm_used == 0) if (rm->rm_used == 0)
out += snprintf(buf + out, len - out, " None\n"); out += scnprintf(buf + out, len - out, " None\n");
else { else {
for (i = 0; i < rm->rm_used; i++) for (i = 0; i < rm->rm_used; i++)
out += snprintf(buf + out, len - out, " %d", out += scnprintf(buf + out, len - out, " %d",
rm->rm_entries[i]); rm->rm_entries[i]);
out += snprintf(buf + out, len - out, "\n"); out += scnprintf(buf + out, len - out, "\n");
} }
spin_unlock(&osb->osb_lock); spin_unlock(&osb->osb_lock);
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => Pid: %d Interval: %lu\n", "Commit", "%10s => Pid: %d Interval: %lu\n", "Commit",
(osb->commit_task ? task_pid_nr(osb->commit_task) : -1), (osb->commit_task ? task_pid_nr(osb->commit_task) : -1),
osb->osb_commit_interval); osb->osb_commit_interval);
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => State: %d TxnId: %lu NumTxns: %d\n", "%10s => State: %d TxnId: %lu NumTxns: %d\n",
"Journal", osb->journal->j_state, "Journal", osb->journal->j_state,
osb->journal->j_trans_id, osb->journal->j_trans_id,
atomic_read(&osb->journal->j_num_trans)); atomic_read(&osb->journal->j_num_trans));
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => GlobalAllocs: %d LocalAllocs: %d " "%10s => GlobalAllocs: %d LocalAllocs: %d "
"SubAllocs: %d LAWinMoves: %d SAExtends: %d\n", "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
"Stats", "Stats",
...@@ -299,7 +299,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len) ...@@ -299,7 +299,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
atomic_read(&osb->alloc_stats.moves), atomic_read(&osb->alloc_stats.moves),
atomic_read(&osb->alloc_stats.bg_extends)); atomic_read(&osb->alloc_stats.bg_extends));
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => State: %u Descriptor: %llu Size: %u bits " "%10s => State: %u Descriptor: %llu Size: %u bits "
"Default: %u bits\n", "Default: %u bits\n",
"LocalAlloc", osb->local_alloc_state, "LocalAlloc", osb->local_alloc_state,
...@@ -307,7 +307,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len) ...@@ -307,7 +307,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
osb->local_alloc_bits, osb->local_alloc_default_bits); osb->local_alloc_bits, osb->local_alloc_default_bits);
spin_lock(&osb->osb_lock); spin_lock(&osb->osb_lock);
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s => InodeSlot: %d StolenInodes: %d, " "%10s => InodeSlot: %d StolenInodes: %d, "
"MetaSlot: %d StolenMeta: %d\n", "Steal", "MetaSlot: %d StolenMeta: %d\n", "Steal",
osb->s_inode_steal_slot, osb->s_inode_steal_slot,
...@@ -316,20 +316,20 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len) ...@@ -316,20 +316,20 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
atomic_read(&osb->s_num_meta_stolen)); atomic_read(&osb->s_num_meta_stolen));
spin_unlock(&osb->osb_lock); spin_unlock(&osb->osb_lock);
out += snprintf(buf + out, len - out, "OrphanScan => "); out += scnprintf(buf + out, len - out, "OrphanScan => ");
out += snprintf(buf + out, len - out, "Local: %u Global: %u ", out += scnprintf(buf + out, len - out, "Local: %u Global: %u ",
os->os_count, os->os_seqno); os->os_count, os->os_seqno);
out += snprintf(buf + out, len - out, " Last Scan: "); out += scnprintf(buf + out, len - out, " Last Scan: ");
if (atomic_read(&os->os_state) == ORPHAN_SCAN_INACTIVE) if (atomic_read(&os->os_state) == ORPHAN_SCAN_INACTIVE)
out += snprintf(buf + out, len - out, "Disabled\n"); out += scnprintf(buf + out, len - out, "Disabled\n");
else else
out += snprintf(buf + out, len - out, "%lu seconds ago\n", out += scnprintf(buf + out, len - out, "%lu seconds ago\n",
(unsigned long)(ktime_get_seconds() - os->os_scantime)); (unsigned long)(ktime_get_seconds() - os->os_scantime));
out += snprintf(buf + out, len - out, "%10s => %3s %10s\n", out += scnprintf(buf + out, len - out, "%10s => %3s %10s\n",
"Slots", "Num", "RecoGen"); "Slots", "Num", "RecoGen");
for (i = 0; i < osb->max_slots; ++i) { for (i = 0; i < osb->max_slots; ++i) {
out += snprintf(buf + out, len - out, out += scnprintf(buf + out, len - out,
"%10s %c %3d %10d\n", "%10s %c %3d %10d\n",
" ", " ",
(i == osb->slot_num ? '*' : ' '), (i == osb->slot_num ? '*' : ' '),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment