Skip to content

Commit 466b77b

Browse files
dhowellsAl Viro
authored andcommitted
VFS: fs/cachefiles: d_backing_inode() annotations
Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent dea655c commit 466b77b

File tree

6 files changed

+62
-62
lines changed

6 files changed

+62
-62
lines changed

fs/cachefiles/bind.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
123123

124124
/* check parameters */
125125
ret = -EOPNOTSUPP;
126-
if (!root->d_inode ||
127-
!root->d_inode->i_op->lookup ||
128-
!root->d_inode->i_op->mkdir ||
129-
!root->d_inode->i_op->setxattr ||
130-
!root->d_inode->i_op->getxattr ||
126+
if (d_is_negative(root) ||
127+
!d_backing_inode(root)->i_op->lookup ||
128+
!d_backing_inode(root)->i_op->mkdir ||
129+
!d_backing_inode(root)->i_op->setxattr ||
130+
!d_backing_inode(root)->i_op->getxattr ||
131131
!root->d_sb->s_op->statfs ||
132132
!root->d_sb->s_op->sync_fs)
133133
goto error_unsupported;

fs/cachefiles/interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object)
441441

442442
fscache_set_store_limit(&object->fscache, ni_size);
443443

444-
oi_size = i_size_read(object->backer->d_inode);
444+
oi_size = i_size_read(d_backing_inode(object->backer));
445445
if (oi_size == ni_size)
446446
return 0;
447447

fs/cachefiles/namei.c

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
355355
return -EIO;
356356
}
357357

358-
if (grave->d_inode) {
358+
if (d_is_positive(grave)) {
359359
unlock_rename(cache->graveyard, dir);
360360
dput(grave);
361361
grave = NULL;
@@ -415,7 +415,7 @@ int cachefiles_delete_object(struct cachefiles_cache *cache,
415415
_enter(",OBJ%x{%p}", object->fscache.debug_id, object->dentry);
416416

417417
ASSERT(object->dentry);
418-
ASSERT(object->dentry->d_inode);
418+
ASSERT(d_backing_inode(object->dentry));
419419
ASSERT(object->dentry->d_parent);
420420

421421
dir = dget_parent(object->dentry);
@@ -473,7 +473,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
473473
path.mnt = cache->mnt;
474474

475475
ASSERT(parent->dentry);
476-
ASSERT(parent->dentry->d_inode);
476+
ASSERT(d_backing_inode(parent->dentry));
477477

478478
if (!(d_is_dir(parent->dentry))) {
479479
// TODO: convert file to dir
@@ -505,21 +505,21 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
505505
if (IS_ERR(next))
506506
goto lookup_error;
507507

508-
_debug("next -> %p %s", next, next->d_inode ? "positive" : "negative");
508+
_debug("next -> %p %s", next, d_backing_inode(next) ? "positive" : "negative");
509509

510510
if (!key)
511-
object->new = !next->d_inode;
511+
object->new = !d_backing_inode(next);
512512

513513
/* if this element of the path doesn't exist, then the lookup phase
514514
* failed, and we can release any readers in the certain knowledge that
515515
* there's nothing for them to actually read */
516-
if (!next->d_inode)
516+
if (d_is_negative(next))
517517
fscache_object_lookup_negative(&object->fscache);
518518

519519
/* we need to create the object if it's negative */
520520
if (key || object->type == FSCACHE_COOKIE_TYPE_INDEX) {
521521
/* index objects and intervening tree levels must be subdirs */
522-
if (!next->d_inode) {
522+
if (d_is_negative(next)) {
523523
ret = cachefiles_has_space(cache, 1, 0);
524524
if (ret < 0)
525525
goto create_error;
@@ -534,21 +534,21 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
534534
if (ret < 0)
535535
goto create_error;
536536

537-
ASSERT(next->d_inode);
537+
ASSERT(d_backing_inode(next));
538538

539539
_debug("mkdir -> %p{%p{ino=%lu}}",
540-
next, next->d_inode, next->d_inode->i_ino);
540+
next, d_backing_inode(next), d_backing_inode(next)->i_ino);
541541

542542
} else if (!d_can_lookup(next)) {
543543
pr_err("inode %lu is not a directory\n",
544-
next->d_inode->i_ino);
544+
d_backing_inode(next)->i_ino);
545545
ret = -ENOBUFS;
546546
goto error;
547547
}
548548

549549
} else {
550550
/* non-index objects start out life as files */
551-
if (!next->d_inode) {
551+
if (d_is_negative(next)) {
552552
ret = cachefiles_has_space(cache, 1, 0);
553553
if (ret < 0)
554554
goto create_error;
@@ -563,16 +563,16 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
563563
if (ret < 0)
564564
goto create_error;
565565

566-
ASSERT(next->d_inode);
566+
ASSERT(d_backing_inode(next));
567567

568568
_debug("create -> %p{%p{ino=%lu}}",
569-
next, next->d_inode, next->d_inode->i_ino);
569+
next, d_backing_inode(next), d_backing_inode(next)->i_ino);
570570

571571
} else if (!d_can_lookup(next) &&
572572
!d_is_reg(next)
573573
) {
574574
pr_err("inode %lu is not a file or directory\n",
575-
next->d_inode->i_ino);
575+
d_backing_inode(next)->i_ino);
576576
ret = -ENOBUFS;
577577
goto error;
578578
}
@@ -646,7 +646,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
646646
const struct address_space_operations *aops;
647647

648648
ret = -EPERM;
649-
aops = object->dentry->d_inode->i_mapping->a_ops;
649+
aops = d_backing_inode(object->dentry)->i_mapping->a_ops;
650650
if (!aops->bmap)
651651
goto check_error;
652652

@@ -659,7 +659,7 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
659659
object->new = 0;
660660
fscache_obtained_object(&object->fscache);
661661

662-
_leave(" = 0 [%lu]", object->dentry->d_inode->i_ino);
662+
_leave(" = 0 [%lu]", d_backing_inode(object->dentry)->i_ino);
663663
return 0;
664664

665665
create_error:
@@ -731,10 +731,10 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
731731
}
732732

733733
_debug("subdir -> %p %s",
734-
subdir, subdir->d_inode ? "positive" : "negative");
734+
subdir, d_backing_inode(subdir) ? "positive" : "negative");
735735

736736
/* we need to create the subdir if it doesn't exist yet */
737-
if (!subdir->d_inode) {
737+
if (d_is_negative(subdir)) {
738738
ret = cachefiles_has_space(cache, 1, 0);
739739
if (ret < 0)
740740
goto mkdir_error;
@@ -750,18 +750,18 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
750750
if (ret < 0)
751751
goto mkdir_error;
752752

753-
ASSERT(subdir->d_inode);
753+
ASSERT(d_backing_inode(subdir));
754754

755755
_debug("mkdir -> %p{%p{ino=%lu}}",
756756
subdir,
757-
subdir->d_inode,
758-
subdir->d_inode->i_ino);
757+
d_backing_inode(subdir),
758+
d_backing_inode(subdir)->i_ino);
759759
}
760760

761761
mutex_unlock(&d_inode(dir)->i_mutex);
762762

763763
/* we need to make sure the subdir is a directory */
764-
ASSERT(subdir->d_inode);
764+
ASSERT(d_backing_inode(subdir));
765765

766766
if (!d_can_lookup(subdir)) {
767767
pr_err("%s is not a directory\n", dirname);
@@ -770,18 +770,18 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
770770
}
771771

772772
ret = -EPERM;
773-
if (!subdir->d_inode->i_op->setxattr ||
774-
!subdir->d_inode->i_op->getxattr ||
775-
!subdir->d_inode->i_op->lookup ||
776-
!subdir->d_inode->i_op->mkdir ||
777-
!subdir->d_inode->i_op->create ||
778-
(!subdir->d_inode->i_op->rename &&
779-
!subdir->d_inode->i_op->rename2) ||
780-
!subdir->d_inode->i_op->rmdir ||
781-
!subdir->d_inode->i_op->unlink)
773+
if (!d_backing_inode(subdir)->i_op->setxattr ||
774+
!d_backing_inode(subdir)->i_op->getxattr ||
775+
!d_backing_inode(subdir)->i_op->lookup ||
776+
!d_backing_inode(subdir)->i_op->mkdir ||
777+
!d_backing_inode(subdir)->i_op->create ||
778+
(!d_backing_inode(subdir)->i_op->rename &&
779+
!d_backing_inode(subdir)->i_op->rename2) ||
780+
!d_backing_inode(subdir)->i_op->rmdir ||
781+
!d_backing_inode(subdir)->i_op->unlink)
782782
goto check_error;
783783

784-
_leave(" = [%lu]", subdir->d_inode->i_ino);
784+
_leave(" = [%lu]", d_backing_inode(subdir)->i_ino);
785785
return subdir;
786786

787787
check_error:
@@ -836,12 +836,12 @@ static struct dentry *cachefiles_check_active(struct cachefiles_cache *cache,
836836
goto lookup_error;
837837

838838
//_debug("victim -> %p %s",
839-
// victim, victim->d_inode ? "positive" : "negative");
839+
// victim, d_backing_inode(victim) ? "positive" : "negative");
840840

841841
/* if the object is no longer there then we probably retired the object
842842
* at the netfs's request whilst the cull was in progress
843843
*/
844-
if (!victim->d_inode) {
844+
if (d_is_negative(victim)) {
845845
mutex_unlock(&d_inode(dir)->i_mutex);
846846
dput(victim);
847847
_leave(" = -ENOENT [absent]");
@@ -913,7 +913,7 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir,
913913
return PTR_ERR(victim);
914914

915915
_debug("victim -> %p %s",
916-
victim, victim->d_inode ? "positive" : "negative");
916+
victim, d_backing_inode(victim) ? "positive" : "negative");
917917

918918
/* okay... the victim is not being used so we can cull it
919919
* - start by marking it as stale

fs/cachefiles/rdwr.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ static int cachefiles_read_waiter(wait_queue_t *wait, unsigned mode,
7474
static int cachefiles_read_reissue(struct cachefiles_object *object,
7575
struct cachefiles_one_read *monitor)
7676
{
77-
struct address_space *bmapping = object->backer->d_inode->i_mapping;
77+
struct address_space *bmapping = d_backing_inode(object->backer)->i_mapping;
7878
struct page *backpage = monitor->back_page, *backpage2;
7979
int ret;
8080

8181
_enter("{ino=%lx},{%lx,%lx}",
82-
object->backer->d_inode->i_ino,
82+
d_backing_inode(object->backer)->i_ino,
8383
backpage->index, backpage->flags);
8484

8585
/* skip if the page was truncated away completely */
@@ -157,7 +157,7 @@ static void cachefiles_read_copier(struct fscache_operation *_op)
157157
object = container_of(op->op.object,
158158
struct cachefiles_object, fscache);
159159

160-
_enter("{ino=%lu}", object->backer->d_inode->i_ino);
160+
_enter("{ino=%lu}", d_backing_inode(object->backer)->i_ino);
161161

162162
max = 8;
163163
spin_lock_irq(&object->work_lock);
@@ -247,7 +247,7 @@ static int cachefiles_read_backing_file_one(struct cachefiles_object *object,
247247
init_waitqueue_func_entry(&monitor->monitor, cachefiles_read_waiter);
248248

249249
/* attempt to get hold of the backing page */
250-
bmapping = object->backer->d_inode->i_mapping;
250+
bmapping = d_backing_inode(object->backer)->i_mapping;
251251
newpage = NULL;
252252

253253
for (;;) {
@@ -408,7 +408,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
408408
if (!object->backer)
409409
goto enobufs;
410410

411-
inode = object->backer->d_inode;
411+
inode = d_backing_inode(object->backer);
412412
ASSERT(S_ISREG(inode->i_mode));
413413
ASSERT(inode->i_mapping->a_ops->bmap);
414414
ASSERT(inode->i_mapping->a_ops->readpages);
@@ -468,7 +468,7 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object,
468468
struct list_head *list)
469469
{
470470
struct cachefiles_one_read *monitor = NULL;
471-
struct address_space *bmapping = object->backer->d_inode->i_mapping;
471+
struct address_space *bmapping = d_backing_inode(object->backer)->i_mapping;
472472
struct page *newpage = NULL, *netpage, *_n, *backpage = NULL;
473473
int ret = 0;
474474

@@ -705,7 +705,7 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,
705705
if (cachefiles_has_space(cache, 0, *nr_pages) < 0)
706706
space = 0;
707707

708-
inode = object->backer->d_inode;
708+
inode = d_backing_inode(object->backer);
709709
ASSERT(S_ISREG(inode->i_mode));
710710
ASSERT(inode->i_mapping->a_ops->bmap);
711711
ASSERT(inode->i_mapping->a_ops->readpages);

fs/cachefiles/security.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ static int cachefiles_check_cache_dir(struct cachefiles_cache *cache,
5555
{
5656
int ret;
5757

58-
ret = security_inode_mkdir(root->d_inode, root, 0);
58+
ret = security_inode_mkdir(d_backing_inode(root), root, 0);
5959
if (ret < 0) {
6060
pr_err("Security denies permission to make dirs: error %d",
6161
ret);
6262
return ret;
6363
}
6464

65-
ret = security_inode_create(root->d_inode, root, 0);
65+
ret = security_inode_create(d_backing_inode(root), root, 0);
6666
if (ret < 0)
6767
pr_err("Security denies permission to create files: error %d",
6868
ret);
@@ -95,7 +95,7 @@ int cachefiles_determine_cache_security(struct cachefiles_cache *cache,
9595

9696
/* use the cache root dir's security context as the basis with
9797
* which create files */
98-
ret = set_create_files_as(new, root->d_inode);
98+
ret = set_create_files_as(new, d_backing_inode(root));
9999
if (ret < 0) {
100100
abort_creds(new);
101101
cachefiles_begin_secure(cache, _saved_cred);

0 commit comments

Comments
 (0)