diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-22 15:40:57 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-22 18:04:28 -0500 |
commit | 5955102c9984fa081b2d570cfac75c97eecf8f3b (patch) | |
tree | a4744386eac4b916e847eb4eedfada158f6527b4 /fs/cachefiles | |
parent | 57b8f112cfe6622ddddb8c2641206bb5fa8a112d (diff) |
wrappers for ->i_mutex access
parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
inode_foo(inode) being mutex_foo(&inode->i_mutex).
Please, use those for access to ->i_mutex; over the coming cycle
->i_mutex will become rwsem, with ->lookup() done with it held
only shared.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/cachefiles')
-rw-r--r-- | fs/cachefiles/interface.c | 4 | ||||
-rw-r--r-- | fs/cachefiles/namei.c | 40 |
2 files changed, 22 insertions, 22 deletions
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c index afa023dded5b..675a3332d72f 100644 --- a/fs/cachefiles/interface.c +++ b/fs/cachefiles/interface.c | |||
@@ -446,7 +446,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object) | |||
446 | return 0; | 446 | return 0; |
447 | 447 | ||
448 | cachefiles_begin_secure(cache, &saved_cred); | 448 | cachefiles_begin_secure(cache, &saved_cred); |
449 | mutex_lock(&d_inode(object->backer)->i_mutex); | 449 | inode_lock(d_inode(object->backer)); |
450 | 450 | ||
451 | /* if there's an extension to a partial page at the end of the backing | 451 | /* if there's an extension to a partial page at the end of the backing |
452 | * file, we need to discard the partial page so that we pick up new | 452 | * file, we need to discard the partial page so that we pick up new |
@@ -465,7 +465,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object) | |||
465 | ret = notify_change(object->backer, &newattrs, NULL); | 465 | ret = notify_change(object->backer, &newattrs, NULL); |
466 | 466 | ||
467 | truncate_failed: | 467 | truncate_failed: |
468 | mutex_unlock(&d_inode(object->backer)->i_mutex); | 468 | inode_unlock(d_inode(object->backer)); |
469 | cachefiles_end_secure(cache, saved_cred); | 469 | cachefiles_end_secure(cache, saved_cred); |
470 | 470 | ||
471 | if (ret == -EIO) { | 471 | if (ret == -EIO) { |
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index c4b893453e0e..1c2334c163dd 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c | |||
@@ -295,7 +295,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache, | |||
295 | cachefiles_mark_object_buried(cache, rep, why); | 295 | cachefiles_mark_object_buried(cache, rep, why); |
296 | } | 296 | } |
297 | 297 | ||
298 | mutex_unlock(&d_inode(dir)->i_mutex); | 298 | inode_unlock(d_inode(dir)); |
299 | 299 | ||
300 | if (ret == -EIO) | 300 | if (ret == -EIO) |
301 | cachefiles_io_error(cache, "Unlink failed"); | 301 | cachefiles_io_error(cache, "Unlink failed"); |
@@ -306,7 +306,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache, | |||
306 | 306 | ||
307 | /* directories have to be moved to the graveyard */ | 307 | /* directories have to be moved to the graveyard */ |
308 | _debug("move stale object to graveyard"); | 308 | _debug("move stale object to graveyard"); |
309 | mutex_unlock(&d_inode(dir)->i_mutex); | 309 | inode_unlock(d_inode(dir)); |
310 | 310 | ||
311 | try_again: | 311 | try_again: |
312 | /* first step is to make up a grave dentry in the graveyard */ | 312 | /* first step is to make up a grave dentry in the graveyard */ |
@@ -423,13 +423,13 @@ int cachefiles_delete_object(struct cachefiles_cache *cache, | |||
423 | 423 | ||
424 | dir = dget_parent(object->dentry); | 424 | dir = dget_parent(object->dentry); |
425 | 425 | ||
426 | mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT); | 426 | inode_lock_nested(d_inode(dir), I_MUTEX_PARENT); |
427 | 427 | ||
428 | if (test_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->fscache.flags)) { | 428 | if (test_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->fscache.flags)) { |
429 | /* object allocation for the same key preemptively deleted this | 429 | /* object allocation for the same key preemptively deleted this |
430 | * object's file so that it could create its own file */ | 430 | * object's file so that it could create its own file */ |
431 | _debug("object preemptively buried"); | 431 | _debug("object preemptively buried"); |
432 | mutex_unlock(&d_inode(dir)->i_mutex); | 432 | inode_unlock(d_inode(dir)); |
433 | ret = 0; | 433 | ret = 0; |
434 | } else { | 434 | } else { |
435 | /* we need to check that our parent is _still_ our parent - it | 435 | /* we need to check that our parent is _still_ our parent - it |
@@ -442,7 +442,7 @@ int cachefiles_delete_object(struct cachefiles_cache *cache, | |||
442 | /* it got moved, presumably by cachefilesd culling it, | 442 | /* it got moved, presumably by cachefilesd culling it, |
443 | * so it's no longer in the key path and we can ignore | 443 | * so it's no longer in the key path and we can ignore |
444 | * it */ | 444 | * it */ |
445 | mutex_unlock(&d_inode(dir)->i_mutex); | 445 | inode_unlock(d_inode(dir)); |
446 | ret = 0; | 446 | ret = 0; |
447 | } | 447 | } |
448 | } | 448 | } |
@@ -501,7 +501,7 @@ lookup_again: | |||
501 | /* search the current directory for the element name */ | 501 | /* search the current directory for the element name */ |
502 | _debug("lookup '%s'", name); | 502 | _debug("lookup '%s'", name); |
503 | 503 | ||
504 | mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT); | 504 | inode_lock_nested(d_inode(dir), I_MUTEX_PARENT); |
505 | 505 | ||
506 | start = jiffies; | 506 | start = jiffies; |
507 | next = lookup_one_len(name, dir, nlen); | 507 | next = lookup_one_len(name, dir, nlen); |
@@ -585,7 +585,7 @@ lookup_again: | |||
585 | /* process the next component */ | 585 | /* process the next component */ |
586 | if (key) { | 586 | if (key) { |
587 | _debug("advance"); | 587 | _debug("advance"); |
588 | mutex_unlock(&d_inode(dir)->i_mutex); | 588 | inode_unlock(d_inode(dir)); |
589 | dput(dir); | 589 | dput(dir); |
590 | dir = next; | 590 | dir = next; |
591 | next = NULL; | 591 | next = NULL; |
@@ -623,7 +623,7 @@ lookup_again: | |||
623 | /* note that we're now using this object */ | 623 | /* note that we're now using this object */ |
624 | ret = cachefiles_mark_object_active(cache, object); | 624 | ret = cachefiles_mark_object_active(cache, object); |
625 | 625 | ||
626 | mutex_unlock(&d_inode(dir)->i_mutex); | 626 | inode_unlock(d_inode(dir)); |
627 | dput(dir); | 627 | dput(dir); |
628 | dir = NULL; | 628 | dir = NULL; |
629 | 629 | ||
@@ -705,7 +705,7 @@ lookup_error: | |||
705 | cachefiles_io_error(cache, "Lookup failed"); | 705 | cachefiles_io_error(cache, "Lookup failed"); |
706 | next = NULL; | 706 | next = NULL; |
707 | error: | 707 | error: |
708 | mutex_unlock(&d_inode(dir)->i_mutex); | 708 | inode_unlock(d_inode(dir)); |
709 | dput(next); | 709 | dput(next); |
710 | error_out2: | 710 | error_out2: |
711 | dput(dir); | 711 | dput(dir); |
@@ -729,7 +729,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache, | |||
729 | _enter(",,%s", dirname); | 729 | _enter(",,%s", dirname); |
730 | 730 | ||
731 | /* search the current directory for the element name */ | 731 | /* search the current directory for the element name */ |
732 | mutex_lock(&d_inode(dir)->i_mutex); | 732 | inode_lock(d_inode(dir)); |
733 | 733 | ||
734 | start = jiffies; | 734 | start = jiffies; |
735 | subdir = lookup_one_len(dirname, dir, strlen(dirname)); | 735 | subdir = lookup_one_len(dirname, dir, strlen(dirname)); |
@@ -768,7 +768,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache, | |||
768 | d_backing_inode(subdir)->i_ino); | 768 | d_backing_inode(subdir)->i_ino); |
769 | } | 769 | } |
770 | 770 | ||
771 | mutex_unlock(&d_inode(dir)->i_mutex); | 771 | inode_unlock(d_inode(dir)); |
772 | 772 | ||
773 | /* we need to make sure the subdir is a directory */ | 773 | /* we need to make sure the subdir is a directory */ |
774 | ASSERT(d_backing_inode(subdir)); | 774 | ASSERT(d_backing_inode(subdir)); |
@@ -800,19 +800,19 @@ check_error: | |||
800 | return ERR_PTR(ret); | 800 | return ERR_PTR(ret); |
801 | 801 | ||
802 | mkdir_error: | 802 | mkdir_error: |
803 | mutex_unlock(&d_inode(dir)->i_mutex); | 803 | inode_unlock(d_inode(dir)); |
804 | dput(subdir); | 804 | dput(subdir); |
805 | pr_err("mkdir %s failed with error %d\n", dirname, ret); | 805 | pr_err("mkdir %s failed with error %d\n", dirname, ret); |
806 | return ERR_PTR(ret); | 806 | return ERR_PTR(ret); |
807 | 807 | ||
808 | lookup_error: | 808 | lookup_error: |
809 | mutex_unlock(&d_inode(dir)->i_mutex); | 809 | inode_unlock(d_inode(dir)); |
810 | ret = PTR_ERR(subdir); | 810 | ret = PTR_ERR(subdir); |
811 | pr_err("Lookup %s failed with error %d\n", dirname, ret); | 811 | pr_err("Lookup %s failed with error %d\n", dirname, ret); |
812 | return ERR_PTR(ret); | 812 | return ERR_PTR(ret); |
813 | 813 | ||
814 | nomem_d_alloc: | 814 | nomem_d_alloc: |
815 | mutex_unlock(&d_inode(dir)->i_mutex); | 815 | inode_unlock(d_inode(dir)); |
816 | _leave(" = -ENOMEM"); | 816 | _leave(" = -ENOMEM"); |
817 | return ERR_PTR(-ENOMEM); | 817 | return ERR_PTR(-ENOMEM); |
818 | } | 818 | } |
@@ -837,7 +837,7 @@ static struct dentry *cachefiles_check_active(struct cachefiles_cache *cache, | |||
837 | // dir, filename); | 837 | // dir, filename); |
838 | 838 | ||
839 | /* look up the victim */ | 839 | /* look up the victim */ |
840 | mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT); | 840 | inode_lock_nested(d_inode(dir), I_MUTEX_PARENT); |
841 | 841 | ||
842 | start = jiffies; | 842 | start = jiffies; |
843 | victim = lookup_one_len(filename, dir, strlen(filename)); | 843 | victim = lookup_one_len(filename, dir, strlen(filename)); |
@@ -852,7 +852,7 @@ static struct dentry *cachefiles_check_active(struct cachefiles_cache *cache, | |||
852 | * at the netfs's request whilst the cull was in progress | 852 | * at the netfs's request whilst the cull was in progress |
853 | */ | 853 | */ |
854 | if (d_is_negative(victim)) { | 854 | if (d_is_negative(victim)) { |
855 | mutex_unlock(&d_inode(dir)->i_mutex); | 855 | inode_unlock(d_inode(dir)); |
856 | dput(victim); | 856 | dput(victim); |
857 | _leave(" = -ENOENT [absent]"); | 857 | _leave(" = -ENOENT [absent]"); |
858 | return ERR_PTR(-ENOENT); | 858 | return ERR_PTR(-ENOENT); |
@@ -881,13 +881,13 @@ static struct dentry *cachefiles_check_active(struct cachefiles_cache *cache, | |||
881 | 881 | ||
882 | object_in_use: | 882 | object_in_use: |
883 | read_unlock(&cache->active_lock); | 883 | read_unlock(&cache->active_lock); |
884 | mutex_unlock(&d_inode(dir)->i_mutex); | 884 | inode_unlock(d_inode(dir)); |
885 | dput(victim); | 885 | dput(victim); |
886 | //_leave(" = -EBUSY [in use]"); | 886 | //_leave(" = -EBUSY [in use]"); |
887 | return ERR_PTR(-EBUSY); | 887 | return ERR_PTR(-EBUSY); |
888 | 888 | ||
889 | lookup_error: | 889 | lookup_error: |
890 | mutex_unlock(&d_inode(dir)->i_mutex); | 890 | inode_unlock(d_inode(dir)); |
891 | ret = PTR_ERR(victim); | 891 | ret = PTR_ERR(victim); |
892 | if (ret == -ENOENT) { | 892 | if (ret == -ENOENT) { |
893 | /* file or dir now absent - probably retired by netfs */ | 893 | /* file or dir now absent - probably retired by netfs */ |
@@ -947,7 +947,7 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir, | |||
947 | return 0; | 947 | return 0; |
948 | 948 | ||
949 | error_unlock: | 949 | error_unlock: |
950 | mutex_unlock(&d_inode(dir)->i_mutex); | 950 | inode_unlock(d_inode(dir)); |
951 | error: | 951 | error: |
952 | dput(victim); | 952 | dput(victim); |
953 | if (ret == -ENOENT) { | 953 | if (ret == -ENOENT) { |
@@ -982,7 +982,7 @@ int cachefiles_check_in_use(struct cachefiles_cache *cache, struct dentry *dir, | |||
982 | if (IS_ERR(victim)) | 982 | if (IS_ERR(victim)) |
983 | return PTR_ERR(victim); | 983 | return PTR_ERR(victim); |
984 | 984 | ||
985 | mutex_unlock(&d_inode(dir)->i_mutex); | 985 | inode_unlock(d_inode(dir)); |
986 | dput(victim); | 986 | dput(victim); |
987 | //_leave(" = 0"); | 987 | //_leave(" = 0"); |
988 | return 0; | 988 | return 0; |