return 0;
}
-int lfsck_bits_dump(char **buf, int *len, int bits, const char *names[],
+int lfsck_bits_dump(struct seq_file *m, int bits, const char *names[],
const char *prefix)
{
- int save = *len;
int flag;
- int rc;
int i;
bool newline = (bits != 0 ? false : true);
- rc = snprintf(*buf, *len, "%s:%c", prefix, newline ? '\n' : ' ');
- if (rc <= 0)
- return -ENOSPC;
+ seq_printf(m, "%s:%c", prefix, bits != 0 ? ' ' : '\n');
- *buf += rc;
- *len -= rc;
for (i = 0, flag = 1; bits != 0; i++, flag = 1 << i) {
if (flag & bits) {
bits &= ~flag;
if (bits == 0)
newline = true;
- rc = snprintf(*buf, *len, "%s%c", names[i],
- newline ? '\n' : ',');
- if (rc <= 0)
- return -ENOSPC;
-
- *buf += rc;
- *len -= rc;
+ seq_printf(m, "%s%c", names[i],
+ newline ? '\n' : ',');
}
}
}
- if (!newline) {
- rc = snprintf(*buf, *len, "\n");
- if (rc <= 0)
- return -ENOSPC;
-
- *buf += rc;
- *len -= rc;
- }
-
- return save - *len;
+ if (!newline)
+ seq_printf(m, "\n");
+ return 0;
}
-int lfsck_time_dump(char **buf, int *len, __u64 time, const char *prefix)
+int lfsck_time_dump(struct seq_file *m, __u64 time, const char *prefix)
{
- int rc;
-
if (time != 0)
- rc = snprintf(*buf, *len, "%s: "LPU64" seconds\n", prefix,
- cfs_time_current_sec() - time);
+ seq_printf(m, "%s: "LPU64" seconds\n", prefix,
+ cfs_time_current_sec() - time);
else
- rc = snprintf(*buf, *len, "%s: N/A\n", prefix);
- if (rc <= 0)
- return -ENOSPC;
-
- *buf += rc;
- *len -= rc;
- return rc;
+ seq_printf(m, "%s: N/A\n", prefix);
+ return 0;
}
-int lfsck_pos_dump(char **buf, int *len, struct lfsck_position *pos,
+int lfsck_pos_dump(struct seq_file *m, struct lfsck_position *pos,
const char *prefix)
{
- int rc;
-
if (fid_is_zero(&pos->lp_dir_parent)) {
if (pos->lp_oit_cookie == 0)
- rc = snprintf(*buf, *len, "%s: N/A, N/A, N/A\n",
- prefix);
+ seq_printf(m, "%s: N/A, N/A, N/A\n",
+ prefix);
else
- rc = snprintf(*buf, *len, "%s: "LPU64", N/A, N/A\n",
- prefix, pos->lp_oit_cookie);
+ seq_printf(m, "%s: "LPU64", N/A, N/A\n",
+ prefix, pos->lp_oit_cookie);
} else {
- rc = snprintf(*buf, *len, "%s: "LPU64", "DFID", "LPU64"\n",
- prefix, pos->lp_oit_cookie,
- PFID(&pos->lp_dir_parent), pos->lp_dir_cookie);
+ seq_printf(m, "%s: "LPU64", "DFID", "LPU64"\n",
+ prefix, pos->lp_oit_cookie,
+ PFID(&pos->lp_dir_parent), pos->lp_dir_cookie);
}
- if (rc <= 0)
- return -ENOSPC;
-
- *buf += rc;
- *len -= rc;
- return rc;
+ return 0;
}
void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck,
return 1;
}
- /* .lustre doesn't contain "real" user objects, no need lfsck */
- if (fid_is_dot_lustre(lfsck_dto2fid(obj))) {
+ /* No need to check .lustre and its children. */
+ if (fid_seq_is_dot_lustre(fid_seq(lfsck_dto2fid(obj)))) {
if (depth > 0)
lfsck_object_put(env, obj);
return 0;
return 0;
}
- /* Currently, only client visible directory can be remote. */
if (dt_object_remote(obj)) {
+ /* .lustre/lost+found/MDTxxx can be remote directory. */
+ if (fid_seq_is_dot_lustre(fid_seq(lfsck_dto2fid(obj))))
+ rc = 0;
+ else
+ /* Other remote directory should be client
+ * visible and need to be checked. */
+ rc = 1;
lfsck_object_put(env, obj);
- return 1;
+ return rc;
}
depth++;
/* external interfaces */
-int lfsck_get_speed(struct dt_device *key, void *buf, int len)
+int lfsck_get_speed(struct seq_file *m, struct dt_device *key)
{
struct lu_env env;
struct lfsck_instance *lfsck;
lfsck = lfsck_instance_find(key, true, false);
if (likely(lfsck != NULL)) {
- rc = snprintf(buf, len, "%u\n",
- lfsck->li_bookmark_ram.lb_speed_limit);
+ seq_printf(m, "%u\n", lfsck->li_bookmark_ram.lb_speed_limit);
lfsck_instance_put(&env, lfsck);
} else {
rc = -ENXIO;
}
EXPORT_SYMBOL(lfsck_set_speed);
-int lfsck_get_windows(struct dt_device *key, void *buf, int len)
+int lfsck_get_windows(struct seq_file *m, struct dt_device *key)
{
struct lu_env env;
struct lfsck_instance *lfsck;
lfsck = lfsck_instance_find(key, true, false);
if (likely(lfsck != NULL)) {
- rc = snprintf(buf, len, "%u\n",
- lfsck->li_bookmark_ram.lb_async_windows);
+ seq_printf(m, "%u\n", lfsck->li_bookmark_ram.lb_async_windows);
lfsck_instance_put(&env, lfsck);
} else {
rc = -ENXIO;
}
EXPORT_SYMBOL(lfsck_set_windows);
-int lfsck_dump(struct dt_device *key, void *buf, int len, enum lfsck_type type)
+int lfsck_dump(struct seq_file *m, struct dt_device *key, enum lfsck_type type)
{
struct lu_env env;
struct lfsck_instance *lfsck;
if (likely(lfsck != NULL)) {
com = lfsck_component_find(lfsck, type);
if (likely(com != NULL)) {
- rc = com->lc_ops->lfsck_dump(&env, com, buf, len);
+ rc = com->lc_ops->lfsck_dump(&env, com, m);
lfsck_component_put(&env, com);
} else {
rc = -ENOTSUPP;
struct lfsck_component *com;
struct l_wait_info lwi = { 0 };
struct lfsck_thread_args *lta;
- long rc = 0;
+ struct task_struct *task;
+ int rc = 0;
__u16 valid = 0;
__u16 flags = 0;
__u16 type = 1;
spin_lock(&lfsck->li_lock);
if (!thread_is_init(thread) && !thread_is_stopped(thread)) {
rc = -EALREADY;
+ if (unlikely(start == NULL)) {
+ spin_unlock(&lfsck->li_lock);
+ GOTO(out, rc);
+ }
+
while (start->ls_active != 0) {
if (!(type & start->ls_active)) {
type <<= 1;
GOTO(out, rc = PTR_ERR(lta));
__lfsck_set_speed(lfsck, bk->lb_speed_limit);
- rc = PTR_ERR(kthread_run(lfsck_master_engine, lta, "lfsck"));
- if (IS_ERR_VALUE(rc)) {
- CERROR("%s: cannot start LFSCK thread: rc = %ld\n",
+ task = kthread_run(lfsck_master_engine, lta, "lfsck");
+ if (IS_ERR(task)) {
+ rc = PTR_ERR(task);
+ CERROR("%s: cannot start LFSCK thread: rc = %d\n",
lfsck_lfsck2name(lfsck), rc);
lfsck_thread_args_fini(lta);