filecheck.c (8fc2cb4ba03ee3502ec23de825cd133f5388738f) | filecheck.c (5f483c4abb507d068b326f24e4ea3481db9cda06) |
---|---|
1/* -*- mode: c; c-basic-offset: 8; -*- 2 * vim: noexpandtab sw=8 ts=8 sts=0: 3 * 4 * filecheck.c 5 * 6 * Code which implements online file check. 7 * 8 * Copyright (C) 2016 SuSE. All rights reserved. --- 39 unchanged lines hidden (view full) --- 48 "INVALIDINO", 49 "BLOCKECC", 50 "BLOCKNO", 51 "VALIDFLAG", 52 "GENERATION", 53 "UNSUPPORTED" 54}; 55 | 1/* -*- mode: c; c-basic-offset: 8; -*- 2 * vim: noexpandtab sw=8 ts=8 sts=0: 3 * 4 * filecheck.c 5 * 6 * Code which implements online file check. 7 * 8 * Copyright (C) 2016 SuSE. All rights reserved. --- 39 unchanged lines hidden (view full) --- 48 "INVALIDINO", 49 "BLOCKECC", 50 "BLOCKNO", 51 "VALIDFLAG", 52 "GENERATION", 53 "UNSUPPORTED" 54}; 55 |
56static DEFINE_SPINLOCK(ocfs2_filecheck_sysfs_lock); 57static LIST_HEAD(ocfs2_filecheck_sysfs_list); 58 | |
59struct ocfs2_filecheck_entry { 60 struct list_head fe_list; 61 unsigned long fe_ino; 62 unsigned int fe_type; 63 unsigned int fe_done:1; 64 unsigned int fe_status:31; 65}; 66 --- 11 unchanged lines hidden (view full) --- 78 if (!errno) 79 return ocfs2_filecheck_errs[errno]; 80 81 BUG_ON(errno < OCFS2_FILECHECK_ERR_START || 82 errno > OCFS2_FILECHECK_ERR_END); 83 return ocfs2_filecheck_errs[errno - OCFS2_FILECHECK_ERR_START + 1]; 84} 85 | 56struct ocfs2_filecheck_entry { 57 struct list_head fe_list; 58 unsigned long fe_ino; 59 unsigned int fe_type; 60 unsigned int fe_done:1; 61 unsigned int fe_status:31; 62}; 63 --- 11 unchanged lines hidden (view full) --- 75 if (!errno) 76 return ocfs2_filecheck_errs[errno]; 77 78 BUG_ON(errno < OCFS2_FILECHECK_ERR_START || 79 errno > OCFS2_FILECHECK_ERR_END); 80 return ocfs2_filecheck_errs[errno - OCFS2_FILECHECK_ERR_START + 1]; 81} 82 |
86static ssize_t ocfs2_filecheck_show(struct kobject *kobj, 87 struct kobj_attribute *attr, 88 char *buf); 89static ssize_t ocfs2_filecheck_store(struct kobject *kobj, 90 struct kobj_attribute *attr, 91 const char *buf, size_t count); 92static struct kobj_attribute ocfs2_attr_filecheck_chk = | 83static ssize_t ocfs2_filecheck_attr_show(struct kobject *kobj, 84 struct kobj_attribute *attr, 85 char *buf); 86static ssize_t ocfs2_filecheck_attr_store(struct kobject *kobj, 87 struct kobj_attribute *attr, 88 const char *buf, size_t count); 89static struct kobj_attribute ocfs2_filecheck_attr_chk = |
93 __ATTR(check, S_IRUSR | S_IWUSR, | 90 __ATTR(check, S_IRUSR | S_IWUSR, |
94 ocfs2_filecheck_show, 95 ocfs2_filecheck_store); 96static struct kobj_attribute ocfs2_attr_filecheck_fix = | 91 ocfs2_filecheck_attr_show, 92 ocfs2_filecheck_attr_store); 93static struct kobj_attribute ocfs2_filecheck_attr_fix = |
97 __ATTR(fix, S_IRUSR | S_IWUSR, | 94 __ATTR(fix, S_IRUSR | S_IWUSR, |
98 ocfs2_filecheck_show, 99 ocfs2_filecheck_store); 100static struct kobj_attribute ocfs2_attr_filecheck_set = | 95 ocfs2_filecheck_attr_show, 96 ocfs2_filecheck_attr_store); 97static struct kobj_attribute ocfs2_filecheck_attr_set = |
101 __ATTR(set, S_IRUSR | S_IWUSR, | 98 __ATTR(set, S_IRUSR | S_IWUSR, |
102 ocfs2_filecheck_show, 103 ocfs2_filecheck_store); | 99 ocfs2_filecheck_attr_show, 100 ocfs2_filecheck_attr_store); 101static struct attribute *ocfs2_filecheck_attrs[] = { 102 &ocfs2_filecheck_attr_chk.attr, 103 &ocfs2_filecheck_attr_fix.attr, 104 &ocfs2_filecheck_attr_set.attr, 105 NULL 106}; |
104 | 107 |
108static void ocfs2_filecheck_release(struct kobject *kobj) 109{ 110 struct ocfs2_filecheck_sysfs_entry *entry = container_of(kobj, 111 struct ocfs2_filecheck_sysfs_entry, fs_kobj); 112 113 complete(&entry->fs_kobj_unregister); 114} 115 116static ssize_t 117ocfs2_filecheck_show(struct kobject *kobj, struct attribute *attr, char *buf) 118{ 119 ssize_t ret = -EIO; 120 struct kobj_attribute *kattr = container_of(attr, 121 struct kobj_attribute, attr); 122 123 kobject_get(kobj); 124 if (kattr->show) 125 ret = kattr->show(kobj, kattr, buf); 126 kobject_put(kobj); 127 return ret; 128} 129 130static ssize_t 131ocfs2_filecheck_store(struct kobject *kobj, struct attribute *attr, 132 const char *buf, size_t count) 133{ 134 ssize_t ret = -EIO; 135 struct kobj_attribute *kattr = container_of(attr, 136 struct kobj_attribute, attr); 137 138 kobject_get(kobj); 139 if (kattr->store) 140 ret = kattr->store(kobj, kattr, buf, count); 141 kobject_put(kobj); 142 return ret; 143} 144 145static const struct sysfs_ops ocfs2_filecheck_ops = { 146 .show = ocfs2_filecheck_show, 147 .store = ocfs2_filecheck_store, 148}; 149 150static struct kobj_type ocfs2_ktype_filecheck = { 151 .default_attrs = ocfs2_filecheck_attrs, 152 .sysfs_ops = &ocfs2_filecheck_ops, 153 .release = ocfs2_filecheck_release, 154}; 155 |
|
105static void 106ocfs2_filecheck_sysfs_free(struct ocfs2_filecheck_sysfs_entry *entry) 107{ 108 struct ocfs2_filecheck_entry *p; 109 | 156static void 157ocfs2_filecheck_sysfs_free(struct ocfs2_filecheck_sysfs_entry *entry) 158{ 159 struct ocfs2_filecheck_entry *p; 160 |
110 if (!atomic_dec_and_test(&entry->fs_count)) { 111 wait_var_event(&entry->fs_count, 112 !atomic_read(&entry->fs_count)); 113 } 114 | |
115 spin_lock(&entry->fs_fcheck->fc_lock); 116 while (!list_empty(&entry->fs_fcheck->fc_head)) { 117 p = list_first_entry(&entry->fs_fcheck->fc_head, 118 struct ocfs2_filecheck_entry, fe_list); 119 list_del(&p->fe_list); 120 BUG_ON(!p->fe_done); /* To free a undone file check entry */ 121 kfree(p); 122 } 123 spin_unlock(&entry->fs_fcheck->fc_lock); 124 | 161 spin_lock(&entry->fs_fcheck->fc_lock); 162 while (!list_empty(&entry->fs_fcheck->fc_head)) { 163 p = list_first_entry(&entry->fs_fcheck->fc_head, 164 struct ocfs2_filecheck_entry, fe_list); 165 list_del(&p->fe_list); 166 BUG_ON(!p->fe_done); /* To free a undone file check entry */ 167 kfree(p); 168 } 169 spin_unlock(&entry->fs_fcheck->fc_lock); 170 |
125 kset_unregister(entry->fs_fcheckkset); 126 kset_unregister(entry->fs_devicekset); | |
127 kfree(entry->fs_fcheck); | 171 kfree(entry->fs_fcheck); |
128 kfree(entry); | 172 entry->fs_fcheck = NULL; |
129} 130 | 173} 174 |
131static void 132ocfs2_filecheck_sysfs_add(struct ocfs2_filecheck_sysfs_entry *entry) | 175int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb) |
133{ | 176{ |
134 spin_lock(&ocfs2_filecheck_sysfs_lock); 135 list_add_tail(&entry->fs_list, &ocfs2_filecheck_sysfs_list); 136 spin_unlock(&ocfs2_filecheck_sysfs_lock); 137} | 177 int ret; 178 struct ocfs2_filecheck *fcheck; 179 struct ocfs2_filecheck_sysfs_entry *entry = &osb->osb_fc_ent; |
138 | 180 |
139static int ocfs2_filecheck_sysfs_del(const char *devname) 140{ 141 struct ocfs2_filecheck_sysfs_entry *p; 142 143 spin_lock(&ocfs2_filecheck_sysfs_lock); 144 list_for_each_entry(p, &ocfs2_filecheck_sysfs_list, fs_list) { 145 if (!strcmp(p->fs_sb->s_id, devname)) { 146 list_del(&p->fs_list); 147 spin_unlock(&ocfs2_filecheck_sysfs_lock); 148 ocfs2_filecheck_sysfs_free(p); 149 return 0; 150 } 151 } 152 spin_unlock(&ocfs2_filecheck_sysfs_lock); 153 return 1; 154} 155 156static void 157ocfs2_filecheck_sysfs_put(struct ocfs2_filecheck_sysfs_entry *entry) 158{ 159 if (atomic_dec_and_test(&entry->fs_count)) 160 wake_up_var(&entry->fs_count); 161} 162 163static struct ocfs2_filecheck_sysfs_entry * 164ocfs2_filecheck_sysfs_get(const char *devname) 165{ 166 struct ocfs2_filecheck_sysfs_entry *p = NULL; 167 168 spin_lock(&ocfs2_filecheck_sysfs_lock); 169 list_for_each_entry(p, &ocfs2_filecheck_sysfs_list, fs_list) { 170 if (!strcmp(p->fs_sb->s_id, devname)) { 171 atomic_inc(&p->fs_count); 172 spin_unlock(&ocfs2_filecheck_sysfs_lock); 173 return p; 174 } 175 } 176 spin_unlock(&ocfs2_filecheck_sysfs_lock); 177 return NULL; 178} 179 180int ocfs2_filecheck_create_sysfs(struct super_block *sb) 181{ 182 int ret = 0; 183 struct kset *device_kset = NULL; 184 struct kset *fcheck_kset = NULL; 185 struct ocfs2_filecheck *fcheck = NULL; 186 struct ocfs2_filecheck_sysfs_entry *entry = NULL; 187 struct attribute **attrs = NULL; 188 struct attribute_group attrgp; 189 190 if (!ocfs2_kset) | 181 fcheck = kmalloc(sizeof(struct ocfs2_filecheck), GFP_NOFS); 182 if (!fcheck) |
191 return -ENOMEM; 192 | 183 return -ENOMEM; 184 |
193 attrs = kmalloc(sizeof(struct attribute *) * 4, GFP_NOFS); 194 if (!attrs) { 195 ret = -ENOMEM; 196 goto error; 197 } else { 198 attrs[0] = &ocfs2_attr_filecheck_chk.attr; 199 attrs[1] = &ocfs2_attr_filecheck_fix.attr; 200 attrs[2] = &ocfs2_attr_filecheck_set.attr; 201 attrs[3] = NULL; 202 memset(&attrgp, 0, sizeof(attrgp)); 203 attrgp.attrs = attrs; 204 } | 185 INIT_LIST_HEAD(&fcheck->fc_head); 186 spin_lock_init(&fcheck->fc_lock); 187 fcheck->fc_max = OCFS2_FILECHECK_MINSIZE; 188 fcheck->fc_size = 0; 189 fcheck->fc_done = 0; |
205 | 190 |
206 fcheck = kmalloc(sizeof(struct ocfs2_filecheck), GFP_NOFS); 207 if (!fcheck) { 208 ret = -ENOMEM; 209 goto error; 210 } else { 211 INIT_LIST_HEAD(&fcheck->fc_head); 212 spin_lock_init(&fcheck->fc_lock); 213 fcheck->fc_max = OCFS2_FILECHECK_MINSIZE; 214 fcheck->fc_size = 0; 215 fcheck->fc_done = 0; | 191 entry->fs_kobj.kset = osb->osb_dev_kset; 192 init_completion(&entry->fs_kobj_unregister); 193 ret = kobject_init_and_add(&entry->fs_kobj, &ocfs2_ktype_filecheck, 194 NULL, "filecheck"); 195 if (ret) { 196 kfree(fcheck); 197 return ret; |
216 } 217 | 198 } 199 |
218 if (strlen(sb->s_id) <= 0) { 219 mlog(ML_ERROR, 220 "Cannot get device basename when create filecheck sysfs\n"); 221 ret = -ENODEV; 222 goto error; 223 } 224 225 device_kset = kset_create_and_add(sb->s_id, NULL, &ocfs2_kset->kobj); 226 if (!device_kset) { 227 ret = -ENOMEM; 228 goto error; 229 } 230 231 fcheck_kset = kset_create_and_add("filecheck", NULL, 232 &device_kset->kobj); 233 if (!fcheck_kset) { 234 ret = -ENOMEM; 235 goto error; 236 } 237 238 ret = sysfs_create_group(&fcheck_kset->kobj, &attrgp); 239 if (ret) 240 goto error; 241 242 entry = kmalloc(sizeof(struct ocfs2_filecheck_sysfs_entry), GFP_NOFS); 243 if (!entry) { 244 ret = -ENOMEM; 245 goto error; 246 } else { 247 atomic_set(&entry->fs_count, 1); 248 entry->fs_sb = sb; 249 entry->fs_devicekset = device_kset; 250 entry->fs_fcheckkset = fcheck_kset; 251 entry->fs_fcheck = fcheck; 252 ocfs2_filecheck_sysfs_add(entry); 253 } 254 255 kfree(attrs); | 200 entry->fs_fcheck = fcheck; |
256 return 0; | 201 return 0; |
257 258error: 259 kfree(attrs); 260 kfree(entry); 261 kfree(fcheck); 262 kset_unregister(fcheck_kset); 263 kset_unregister(device_kset); 264 return ret; | |
265} 266 | 202} 203 |
267int ocfs2_filecheck_remove_sysfs(struct super_block *sb) | 204void ocfs2_filecheck_remove_sysfs(struct ocfs2_super *osb) |
268{ | 205{ |
269 return ocfs2_filecheck_sysfs_del(sb->s_id); | 206 if (!osb->osb_fc_ent.fs_fcheck) 207 return; 208 209 kobject_del(&osb->osb_fc_ent.fs_kobj); 210 kobject_put(&osb->osb_fc_ent.fs_kobj); 211 wait_for_completion(&osb->osb_fc_ent.fs_kobj_unregister); 212 ocfs2_filecheck_sysfs_free(&osb->osb_fc_ent); |
270} 271 272static int 273ocfs2_filecheck_erase_entries(struct ocfs2_filecheck_sysfs_entry *ent, 274 unsigned int count); 275static int 276ocfs2_filecheck_adjust_max(struct ocfs2_filecheck_sysfs_entry *ent, 277 unsigned int len) --- 77 unchanged lines hidden (view full) --- 355 if (type == OCFS2_FILECHECK_TYPE_SET) 356 args->fa_len = (unsigned int)val; 357 else 358 args->fa_ino = val; 359 360 return 0; 361} 362 | 213} 214 215static int 216ocfs2_filecheck_erase_entries(struct ocfs2_filecheck_sysfs_entry *ent, 217 unsigned int count); 218static int 219ocfs2_filecheck_adjust_max(struct ocfs2_filecheck_sysfs_entry *ent, 220 unsigned int len) --- 77 unchanged lines hidden (view full) --- 298 if (type == OCFS2_FILECHECK_TYPE_SET) 299 args->fa_len = (unsigned int)val; 300 else 301 args->fa_ino = val; 302 303 return 0; 304} 305 |
363static ssize_t ocfs2_filecheck_show(struct kobject *kobj, | 306static ssize_t ocfs2_filecheck_attr_show(struct kobject *kobj, |
364 struct kobj_attribute *attr, 365 char *buf) 366{ 367 368 ssize_t ret = 0, total = 0, remain = PAGE_SIZE; 369 unsigned int type; 370 struct ocfs2_filecheck_entry *p; | 307 struct kobj_attribute *attr, 308 char *buf) 309{ 310 311 ssize_t ret = 0, total = 0, remain = PAGE_SIZE; 312 unsigned int type; 313 struct ocfs2_filecheck_entry *p; |
371 struct ocfs2_filecheck_sysfs_entry *ent; | 314 struct ocfs2_filecheck_sysfs_entry *ent = container_of(kobj, 315 struct ocfs2_filecheck_sysfs_entry, fs_kobj); |
372 373 if (ocfs2_filecheck_type_parse(attr->attr.name, &type)) 374 return -EINVAL; 375 | 316 317 if (ocfs2_filecheck_type_parse(attr->attr.name, &type)) 318 return -EINVAL; 319 |
376 ent = ocfs2_filecheck_sysfs_get(kobj->parent->name); 377 if (!ent) { 378 mlog(ML_ERROR, 379 "Cannot get the corresponding entry via device basename %s\n", 380 kobj->name); 381 return -ENODEV; 382 } 383 | |
384 if (type == OCFS2_FILECHECK_TYPE_SET) { 385 spin_lock(&ent->fs_fcheck->fc_lock); 386 total = snprintf(buf, remain, "%u\n", ent->fs_fcheck->fc_max); 387 spin_unlock(&ent->fs_fcheck->fc_lock); 388 goto exit; 389 } 390 391 ret = snprintf(buf, remain, "INO\t\tDONE\tERROR\n"); --- 17 unchanged lines hidden (view full) --- 409 break; 410 } 411 total += ret; 412 remain -= ret; 413 } 414 spin_unlock(&ent->fs_fcheck->fc_lock); 415 416exit: | 320 if (type == OCFS2_FILECHECK_TYPE_SET) { 321 spin_lock(&ent->fs_fcheck->fc_lock); 322 total = snprintf(buf, remain, "%u\n", ent->fs_fcheck->fc_max); 323 spin_unlock(&ent->fs_fcheck->fc_lock); 324 goto exit; 325 } 326 327 ret = snprintf(buf, remain, "INO\t\tDONE\tERROR\n"); --- 17 unchanged lines hidden (view full) --- 345 break; 346 } 347 total += ret; 348 remain -= ret; 349 } 350 spin_unlock(&ent->fs_fcheck->fc_lock); 351 352exit: |
417 ocfs2_filecheck_sysfs_put(ent); | |
418 return total; 419} 420 | 353 return total; 354} 355 |
421static int | 356static inline int |
422ocfs2_filecheck_erase_entry(struct ocfs2_filecheck_sysfs_entry *ent) 423{ 424 struct ocfs2_filecheck_entry *p; 425 426 list_for_each_entry(p, &ent->fs_fcheck->fc_head, fe_list) { 427 if (p->fe_done) { 428 list_del(&p->fe_list); 429 kfree(p); --- 29 unchanged lines hidden (view full) --- 459{ 460 spin_lock(&ent->fs_fcheck->fc_lock); 461 entry->fe_done = 1; 462 ent->fs_fcheck->fc_done++; 463 spin_unlock(&ent->fs_fcheck->fc_lock); 464} 465 466static unsigned int | 357ocfs2_filecheck_erase_entry(struct ocfs2_filecheck_sysfs_entry *ent) 358{ 359 struct ocfs2_filecheck_entry *p; 360 361 list_for_each_entry(p, &ent->fs_fcheck->fc_head, fe_list) { 362 if (p->fe_done) { 363 list_del(&p->fe_list); 364 kfree(p); --- 29 unchanged lines hidden (view full) --- 394{ 395 spin_lock(&ent->fs_fcheck->fc_lock); 396 entry->fe_done = 1; 397 ent->fs_fcheck->fc_done++; 398 spin_unlock(&ent->fs_fcheck->fc_lock); 399} 400 401static unsigned int |
467ocfs2_filecheck_handle(struct super_block *sb, | 402ocfs2_filecheck_handle(struct ocfs2_super *osb, |
468 unsigned long ino, unsigned int flags) 469{ 470 unsigned int ret = OCFS2_FILECHECK_ERR_SUCCESS; 471 struct inode *inode = NULL; 472 int rc; 473 | 403 unsigned long ino, unsigned int flags) 404{ 405 unsigned int ret = OCFS2_FILECHECK_ERR_SUCCESS; 406 struct inode *inode = NULL; 407 int rc; 408 |
474 inode = ocfs2_iget(OCFS2_SB(sb), ino, flags, 0); | 409 inode = ocfs2_iget(osb, ino, flags, 0); |
475 if (IS_ERR(inode)) { 476 rc = (int)(-(long)inode); 477 if (rc >= OCFS2_FILECHECK_ERR_START && 478 rc < OCFS2_FILECHECK_ERR_END) 479 ret = rc; 480 else 481 ret = OCFS2_FILECHECK_ERR_FAILED; 482 } else 483 iput(inode); 484 485 return ret; 486} 487 488static void 489ocfs2_filecheck_handle_entry(struct ocfs2_filecheck_sysfs_entry *ent, 490 struct ocfs2_filecheck_entry *entry) 491{ | 410 if (IS_ERR(inode)) { 411 rc = (int)(-(long)inode); 412 if (rc >= OCFS2_FILECHECK_ERR_START && 413 rc < OCFS2_FILECHECK_ERR_END) 414 ret = rc; 415 else 416 ret = OCFS2_FILECHECK_ERR_FAILED; 417 } else 418 iput(inode); 419 420 return ret; 421} 422 423static void 424ocfs2_filecheck_handle_entry(struct ocfs2_filecheck_sysfs_entry *ent, 425 struct ocfs2_filecheck_entry *entry) 426{ |
427 struct ocfs2_super *osb = container_of(ent, struct ocfs2_super, 428 osb_fc_ent); 429 |
|
492 if (entry->fe_type == OCFS2_FILECHECK_TYPE_CHK) | 430 if (entry->fe_type == OCFS2_FILECHECK_TYPE_CHK) |
493 entry->fe_status = ocfs2_filecheck_handle(ent->fs_sb, | 431 entry->fe_status = ocfs2_filecheck_handle(osb, |
494 entry->fe_ino, OCFS2_FI_FLAG_FILECHECK_CHK); 495 else if (entry->fe_type == OCFS2_FILECHECK_TYPE_FIX) | 432 entry->fe_ino, OCFS2_FI_FLAG_FILECHECK_CHK); 433 else if (entry->fe_type == OCFS2_FILECHECK_TYPE_FIX) |
496 entry->fe_status = ocfs2_filecheck_handle(ent->fs_sb, | 434 entry->fe_status = ocfs2_filecheck_handle(osb, |
497 entry->fe_ino, OCFS2_FI_FLAG_FILECHECK_FIX); 498 else 499 entry->fe_status = OCFS2_FILECHECK_ERR_UNSUPPORTED; 500 501 ocfs2_filecheck_done_entry(ent, entry); 502} 503 | 435 entry->fe_ino, OCFS2_FI_FLAG_FILECHECK_FIX); 436 else 437 entry->fe_status = OCFS2_FILECHECK_ERR_UNSUPPORTED; 438 439 ocfs2_filecheck_done_entry(ent, entry); 440} 441 |
504static ssize_t ocfs2_filecheck_store(struct kobject *kobj, | 442static ssize_t ocfs2_filecheck_attr_store(struct kobject *kobj, |
505 struct kobj_attribute *attr, 506 const char *buf, size_t count) 507{ | 443 struct kobj_attribute *attr, 444 const char *buf, size_t count) 445{ |
446 ssize_t ret = 0; |
|
508 struct ocfs2_filecheck_args args; 509 struct ocfs2_filecheck_entry *entry; | 447 struct ocfs2_filecheck_args args; 448 struct ocfs2_filecheck_entry *entry; |
510 struct ocfs2_filecheck_sysfs_entry *ent; 511 ssize_t ret = 0; | 449 struct ocfs2_filecheck_sysfs_entry *ent = container_of(kobj, 450 struct ocfs2_filecheck_sysfs_entry, fs_kobj); |
512 513 if (count == 0) 514 return count; 515 | 451 452 if (count == 0) 453 return count; 454 |
516 if (ocfs2_filecheck_args_parse(attr->attr.name, buf, count, &args)) { 517 mlog(ML_ERROR, "Invalid arguments for online file check\n"); | 455 if (ocfs2_filecheck_args_parse(attr->attr.name, buf, count, &args)) |
518 return -EINVAL; | 456 return -EINVAL; |
519 } | |
520 | 457 |
521 ent = ocfs2_filecheck_sysfs_get(kobj->parent->name); 522 if (!ent) { 523 mlog(ML_ERROR, 524 "Cannot get the corresponding entry via device basename %s\n", 525 kobj->parent->name); 526 return -ENODEV; 527 } 528 | |
529 if (args.fa_type == OCFS2_FILECHECK_TYPE_SET) { 530 ret = ocfs2_filecheck_adjust_max(ent, args.fa_len); 531 goto exit; 532 } 533 534 entry = kmalloc(sizeof(struct ocfs2_filecheck_entry), GFP_NOFS); 535 if (!entry) { 536 ret = -ENOMEM; 537 goto exit; 538 } 539 540 spin_lock(&ent->fs_fcheck->fc_lock); 541 if ((ent->fs_fcheck->fc_size >= ent->fs_fcheck->fc_max) && | 458 if (args.fa_type == OCFS2_FILECHECK_TYPE_SET) { 459 ret = ocfs2_filecheck_adjust_max(ent, args.fa_len); 460 goto exit; 461 } 462 463 entry = kmalloc(sizeof(struct ocfs2_filecheck_entry), GFP_NOFS); 464 if (!entry) { 465 ret = -ENOMEM; 466 goto exit; 467 } 468 469 spin_lock(&ent->fs_fcheck->fc_lock); 470 if ((ent->fs_fcheck->fc_size >= ent->fs_fcheck->fc_max) && |
542 (ent->fs_fcheck->fc_done == 0)) { | 471 (ent->fs_fcheck->fc_done == 0)) { |
543 mlog(ML_NOTICE, 544 "Cannot do more file check " 545 "since file check queue(%u) is full now\n", 546 ent->fs_fcheck->fc_max); 547 ret = -EAGAIN; 548 kfree(entry); 549 } else { 550 if ((ent->fs_fcheck->fc_size >= ent->fs_fcheck->fc_max) && --- 13 unchanged lines hidden (view full) --- 564 ent->fs_fcheck->fc_size++; 565 } 566 spin_unlock(&ent->fs_fcheck->fc_lock); 567 568 if (!ret) 569 ocfs2_filecheck_handle_entry(ent, entry); 570 571exit: | 472 mlog(ML_NOTICE, 473 "Cannot do more file check " 474 "since file check queue(%u) is full now\n", 475 ent->fs_fcheck->fc_max); 476 ret = -EAGAIN; 477 kfree(entry); 478 } else { 479 if ((ent->fs_fcheck->fc_size >= ent->fs_fcheck->fc_max) && --- 13 unchanged lines hidden (view full) --- 493 ent->fs_fcheck->fc_size++; 494 } 495 spin_unlock(&ent->fs_fcheck->fc_lock); 496 497 if (!ret) 498 ocfs2_filecheck_handle_entry(ent, entry); 499 500exit: |
572 ocfs2_filecheck_sysfs_put(ent); | |
573 return (!ret ? count : ret); 574} | 501 return (!ret ? count : ret); 502} |