1 /* dir.c: AFS filesystem directory handling
3 * Copyright (C) 2002, 2018 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/kernel.h>
14 #include <linux/namei.h>
15 #include <linux/pagemap.h>
16 #include <linux/swap.h>
17 #include <linux/ctype.h>
18 #include <linux/sched.h>
19 #include <linux/task_io_accounting_ops.h>
23 static struct dentry
*afs_lookup(struct inode
*dir
, struct dentry
*dentry
,
25 static int afs_dir_open(struct inode
*inode
, struct file
*file
);
26 static int afs_readdir(struct file
*file
, struct dir_context
*ctx
);
27 static int afs_d_revalidate(struct dentry
*dentry
, unsigned int flags
);
28 static int afs_d_delete(const struct dentry
*dentry
);
29 static int afs_lookup_one_filldir(struct dir_context
*ctx
, const char *name
, int nlen
,
30 loff_t fpos
, u64 ino
, unsigned dtype
);
31 static int afs_lookup_filldir(struct dir_context
*ctx
, const char *name
, int nlen
,
32 loff_t fpos
, u64 ino
, unsigned dtype
);
33 static int afs_create(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
,
35 static int afs_mkdir(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
);
36 static int afs_rmdir(struct inode
*dir
, struct dentry
*dentry
);
37 static int afs_unlink(struct inode
*dir
, struct dentry
*dentry
);
38 static int afs_link(struct dentry
*from
, struct inode
*dir
,
39 struct dentry
*dentry
);
40 static int afs_symlink(struct inode
*dir
, struct dentry
*dentry
,
42 static int afs_rename(struct inode
*old_dir
, struct dentry
*old_dentry
,
43 struct inode
*new_dir
, struct dentry
*new_dentry
,
45 static int afs_dir_releasepage(struct page
*page
, gfp_t gfp_flags
);
46 static void afs_dir_invalidatepage(struct page
*page
, unsigned int offset
,
49 static int afs_dir_set_page_dirty(struct page
*page
)
51 BUG(); /* This should never happen. */
54 const struct file_operations afs_dir_file_operations
= {
56 .release
= afs_release
,
57 .iterate_shared
= afs_readdir
,
59 .llseek
= generic_file_llseek
,
62 const struct inode_operations afs_dir_inode_operations
= {
67 .symlink
= afs_symlink
,
71 .permission
= afs_permission
,
72 .getattr
= afs_getattr
,
73 .setattr
= afs_setattr
,
74 .listxattr
= afs_listxattr
,
77 const struct address_space_operations afs_dir_aops
= {
78 .set_page_dirty
= afs_dir_set_page_dirty
,
79 .releasepage
= afs_dir_releasepage
,
80 .invalidatepage
= afs_dir_invalidatepage
,
83 const struct dentry_operations afs_fs_dentry_operations
= {
84 .d_revalidate
= afs_d_revalidate
,
85 .d_delete
= afs_d_delete
,
86 .d_release
= afs_d_release
,
87 .d_automount
= afs_d_automount
,
90 struct afs_lookup_one_cookie
{
91 struct dir_context ctx
;
97 struct afs_lookup_cookie
{
98 struct dir_context ctx
;
102 unsigned short nr_fids
;
103 struct afs_file_status
*statuses
;
104 struct afs_callback
*callbacks
;
105 struct afs_fid fids
[50];
109 * check that a directory page is valid
111 static bool afs_dir_check_page(struct afs_vnode
*dvnode
, struct page
*page
,
114 struct afs_xdr_dir_page
*dbuf
;
118 /* Determine how many magic numbers there should be in this page, but
119 * we must take care because the directory may change size under us.
121 off
= page_offset(page
);
125 latter
= i_size
- off
;
126 if (latter
>= PAGE_SIZE
)
130 qty
/= sizeof(union afs_xdr_dir_block
);
134 for (tmp
= 0; tmp
< qty
; tmp
++) {
135 if (dbuf
->blocks
[tmp
].hdr
.magic
!= AFS_DIR_MAGIC
) {
136 printk("kAFS: %s(%lx): bad magic %d/%d is %04hx\n",
137 __func__
, dvnode
->vfs_inode
.i_ino
, tmp
, qty
,
138 ntohs(dbuf
->blocks
[tmp
].hdr
.magic
));
139 trace_afs_dir_check_failed(dvnode
, off
, i_size
);
144 /* Make sure each block is NUL terminated so we can reasonably
145 * use string functions on it. The filenames in the page
146 * *should* be NUL-terminated anyway.
148 ((u8
*)&dbuf
->blocks
[tmp
])[AFS_DIR_BLOCK_SIZE
- 1] = 0;
154 afs_stat_v(dvnode
, n_read_dir
);
162 * open an AFS directory file
164 static int afs_dir_open(struct inode
*inode
, struct file
*file
)
166 _enter("{%lu}", inode
->i_ino
);
168 BUILD_BUG_ON(sizeof(union afs_xdr_dir_block
) != 2048);
169 BUILD_BUG_ON(sizeof(union afs_xdr_dirent
) != 32);
171 if (test_bit(AFS_VNODE_DELETED
, &AFS_FS_I(inode
)->flags
))
174 return afs_open(inode
, file
);
178 * Read the directory into the pagecache in one go, scrubbing the previous
179 * contents. The list of pages is returned, pinning them so that they don't
180 * get reclaimed during the iteration.
182 static struct afs_read
*afs_read_dir(struct afs_vnode
*dvnode
, struct key
*key
)
183 __acquires(&dvnode
->validate_lock
)
185 struct afs_read
*req
;
187 int nr_pages
, nr_inline
, i
, n
;
191 i_size
= i_size_read(&dvnode
->vfs_inode
);
193 return ERR_PTR(-EIO
);
194 if (i_size
> 2048 * 1024)
195 return ERR_PTR(-EFBIG
);
197 _enter("%llu", i_size
);
199 /* Get a request record to hold the page list. We want to hold it
200 * inline if we can, but we don't want to make an order 1 allocation.
202 nr_pages
= (i_size
+ PAGE_SIZE
- 1) / PAGE_SIZE
;
203 nr_inline
= nr_pages
;
204 if (nr_inline
> (PAGE_SIZE
- sizeof(*req
)) / sizeof(struct page
*))
207 req
= kzalloc(sizeof(*req
) + sizeof(struct page
*) * nr_inline
,
210 return ERR_PTR(-ENOMEM
);
212 refcount_set(&req
->usage
, 1);
213 req
->nr_pages
= nr_pages
;
214 req
->actual_len
= i_size
; /* May change */
215 req
->len
= nr_pages
* PAGE_SIZE
; /* We can ask for more than there is */
216 req
->data_version
= dvnode
->status
.data_version
; /* May change */
218 req
->pages
= req
->array
;
220 req
->pages
= kcalloc(nr_pages
, sizeof(struct page
*),
226 /* Get a list of all the pages that hold or will hold the directory
227 * content. We need to fill in any gaps that we might find where the
228 * memory reclaimer has been at work. If there are any gaps, we will
229 * need to reread the entire directory contents.
233 n
= find_get_pages_contig(dvnode
->vfs_inode
.i_mapping
, i
,
236 _debug("find %u at %u/%u", n
, i
, req
->nr_pages
);
238 gfp_t gfp
= dvnode
->vfs_inode
.i_mapping
->gfp_mask
;
240 if (test_and_clear_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
))
241 afs_stat_v(dvnode
, n_inval
);
244 req
->pages
[i
] = __page_cache_alloc(gfp
);
247 ret
= add_to_page_cache_lru(req
->pages
[i
],
248 dvnode
->vfs_inode
.i_mapping
,
253 set_page_private(req
->pages
[i
], 1);
254 SetPagePrivate(req
->pages
[i
]);
255 unlock_page(req
->pages
[i
]);
260 } while (i
< req
->nr_pages
);
262 /* If we're going to reload, we need to lock all the pages to prevent
266 if (down_read_killable(&dvnode
->validate_lock
) < 0)
269 if (test_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
))
272 up_read(&dvnode
->validate_lock
);
273 if (down_write_killable(&dvnode
->validate_lock
) < 0)
276 if (!test_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
)) {
277 ret
= afs_fetch_data(dvnode
, key
, req
);
281 task_io_account_read(PAGE_SIZE
* req
->nr_pages
);
283 if (req
->len
< req
->file_size
)
284 goto content_has_grown
;
286 /* Validate the data we just read. */
288 for (i
= 0; i
< req
->nr_pages
; i
++)
289 if (!afs_dir_check_page(dvnode
, req
->pages
[i
],
293 // TODO: Trim excess pages
295 set_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
);
298 downgrade_write(&dvnode
->validate_lock
);
303 up_write(&dvnode
->validate_lock
);
306 _leave(" = %d", ret
);
310 up_write(&dvnode
->validate_lock
);
316 * deal with one block in an AFS directory
318 static int afs_dir_iterate_block(struct dir_context
*ctx
,
319 union afs_xdr_dir_block
*block
,
322 union afs_xdr_dirent
*dire
;
323 unsigned offset
, next
, curr
;
327 _enter("%u,%x,%p,,",(unsigned)ctx
->pos
,blkoff
,block
);
329 curr
= (ctx
->pos
- blkoff
) / sizeof(union afs_xdr_dirent
);
331 /* walk through the block, an entry at a time */
332 for (offset
= (blkoff
== 0 ? AFS_DIR_RESV_BLOCKS0
: AFS_DIR_RESV_BLOCKS
);
333 offset
< AFS_DIR_SLOTS_PER_BLOCK
;
338 /* skip entries marked unused in the bitmap */
339 if (!(block
->hdr
.bitmap
[offset
/ 8] &
340 (1 << (offset
% 8)))) {
341 _debug("ENT[%zu.%u]: unused",
342 blkoff
/ sizeof(union afs_xdr_dir_block
), offset
);
345 next
* sizeof(union afs_xdr_dirent
);
349 /* got a valid entry */
350 dire
= &block
->dirents
[offset
];
351 nlen
= strnlen(dire
->u
.name
,
353 offset
* sizeof(union afs_xdr_dirent
));
355 _debug("ENT[%zu.%u]: %s %zu \"%s\"",
356 blkoff
/ sizeof(union afs_xdr_dir_block
), offset
,
357 (offset
< curr
? "skip" : "fill"),
360 /* work out where the next possible entry is */
361 for (tmp
= nlen
; tmp
> 15; tmp
-= sizeof(union afs_xdr_dirent
)) {
362 if (next
>= AFS_DIR_SLOTS_PER_BLOCK
) {
363 _debug("ENT[%zu.%u]:"
364 " %u travelled beyond end dir block"
366 blkoff
/ sizeof(union afs_xdr_dir_block
),
367 offset
, next
, tmp
, nlen
);
370 if (!(block
->hdr
.bitmap
[next
/ 8] &
371 (1 << (next
% 8)))) {
372 _debug("ENT[%zu.%u]:"
373 " %u unmarked extension (len %u/%zu)",
374 blkoff
/ sizeof(union afs_xdr_dir_block
),
375 offset
, next
, tmp
, nlen
);
379 _debug("ENT[%zu.%u]: ext %u/%zu",
380 blkoff
/ sizeof(union afs_xdr_dir_block
),
385 /* skip if starts before the current position */
389 /* found the next entry */
390 if (!dir_emit(ctx
, dire
->u
.name
, nlen
,
391 ntohl(dire
->u
.vnode
),
392 (ctx
->actor
== afs_lookup_filldir
||
393 ctx
->actor
== afs_lookup_one_filldir
)?
394 ntohl(dire
->u
.unique
) : DT_UNKNOWN
)) {
395 _leave(" = 0 [full]");
399 ctx
->pos
= blkoff
+ next
* sizeof(union afs_xdr_dirent
);
402 _leave(" = 1 [more]");
407 * iterate through the data blob that lists the contents of an AFS directory
409 static int afs_dir_iterate(struct inode
*dir
, struct dir_context
*ctx
,
412 struct afs_vnode
*dvnode
= AFS_FS_I(dir
);
413 struct afs_xdr_dir_page
*dbuf
;
414 union afs_xdr_dir_block
*dblock
;
415 struct afs_read
*req
;
417 unsigned blkoff
, limit
;
420 _enter("{%lu},%u,,", dir
->i_ino
, (unsigned)ctx
->pos
);
422 if (test_bit(AFS_VNODE_DELETED
, &AFS_FS_I(dir
)->flags
)) {
423 _leave(" = -ESTALE");
427 req
= afs_read_dir(dvnode
, key
);
431 /* round the file position up to the next entry boundary */
432 ctx
->pos
+= sizeof(union afs_xdr_dirent
) - 1;
433 ctx
->pos
&= ~(sizeof(union afs_xdr_dirent
) - 1);
435 /* walk through the blocks in sequence */
437 while (ctx
->pos
< req
->actual_len
) {
438 blkoff
= ctx
->pos
& ~(sizeof(union afs_xdr_dir_block
) - 1);
440 /* Fetch the appropriate page from the directory and re-add it
443 page
= req
->pages
[blkoff
/ PAGE_SIZE
];
448 mark_page_accessed(page
);
450 limit
= blkoff
& ~(PAGE_SIZE
- 1);
454 /* deal with the individual blocks stashed on this page */
456 dblock
= &dbuf
->blocks
[(blkoff
% PAGE_SIZE
) /
457 sizeof(union afs_xdr_dir_block
)];
458 ret
= afs_dir_iterate_block(ctx
, dblock
, blkoff
);
464 blkoff
+= sizeof(union afs_xdr_dir_block
);
466 } while (ctx
->pos
< dir
->i_size
&& blkoff
< limit
);
473 up_read(&dvnode
->validate_lock
);
475 _leave(" = %d", ret
);
480 * read an AFS directory
482 static int afs_readdir(struct file
*file
, struct dir_context
*ctx
)
484 return afs_dir_iterate(file_inode(file
), ctx
, afs_file_key(file
));
488 * Search the directory for a single name
489 * - if afs_dir_iterate_block() spots this function, it'll pass the FID
490 * uniquifier through dtype
492 static int afs_lookup_one_filldir(struct dir_context
*ctx
, const char *name
,
493 int nlen
, loff_t fpos
, u64 ino
, unsigned dtype
)
495 struct afs_lookup_one_cookie
*cookie
=
496 container_of(ctx
, struct afs_lookup_one_cookie
, ctx
);
498 _enter("{%s,%u},%s,%u,,%llu,%u",
499 cookie
->name
.name
, cookie
->name
.len
, name
, nlen
,
500 (unsigned long long) ino
, dtype
);
502 /* insanity checks first */
503 BUILD_BUG_ON(sizeof(union afs_xdr_dir_block
) != 2048);
504 BUILD_BUG_ON(sizeof(union afs_xdr_dirent
) != 32);
506 if (cookie
->name
.len
!= nlen
||
507 memcmp(cookie
->name
.name
, name
, nlen
) != 0) {
512 cookie
->fid
.vnode
= ino
;
513 cookie
->fid
.unique
= dtype
;
516 _leave(" = -1 [found]");
521 * Do a lookup of a single name in a directory
522 * - just returns the FID the dentry name maps to if found
524 static int afs_do_lookup_one(struct inode
*dir
, struct dentry
*dentry
,
525 struct afs_fid
*fid
, struct key
*key
)
527 struct afs_super_info
*as
= dir
->i_sb
->s_fs_info
;
528 struct afs_lookup_one_cookie cookie
= {
529 .ctx
.actor
= afs_lookup_one_filldir
,
530 .name
= dentry
->d_name
,
531 .fid
.vid
= as
->volume
->vid
535 _enter("{%lu},%p{%pd},", dir
->i_ino
, dentry
, dentry
);
537 /* search the directory */
538 ret
= afs_dir_iterate(dir
, &cookie
.ctx
, key
);
540 _leave(" = %d [iter]", ret
);
546 _leave(" = -ENOENT [not found]");
551 _leave(" = 0 { vn=%u u=%u }", fid
->vnode
, fid
->unique
);
556 * search the directory for a name
557 * - if afs_dir_iterate_block() spots this function, it'll pass the FID
558 * uniquifier through dtype
560 static int afs_lookup_filldir(struct dir_context
*ctx
, const char *name
,
561 int nlen
, loff_t fpos
, u64 ino
, unsigned dtype
)
563 struct afs_lookup_cookie
*cookie
=
564 container_of(ctx
, struct afs_lookup_cookie
, ctx
);
567 _enter("{%s,%u},%s,%u,,%llu,%u",
568 cookie
->name
.name
, cookie
->name
.len
, name
, nlen
,
569 (unsigned long long) ino
, dtype
);
571 /* insanity checks first */
572 BUILD_BUG_ON(sizeof(union afs_xdr_dir_block
) != 2048);
573 BUILD_BUG_ON(sizeof(union afs_xdr_dirent
) != 32);
576 if (cookie
->nr_fids
< 50) {
577 cookie
->fids
[cookie
->nr_fids
].vnode
= ino
;
578 cookie
->fids
[cookie
->nr_fids
].unique
= dtype
;
581 } else if (cookie
->name
.len
== nlen
&&
582 memcmp(cookie
->name
.name
, name
, nlen
) == 0) {
583 cookie
->fids
[0].vnode
= ino
;
584 cookie
->fids
[0].unique
= dtype
;
586 if (cookie
->one_only
)
590 ret
= cookie
->nr_fids
>= 50 ? -1 : 0;
591 _leave(" = %d", ret
);
596 * Do a lookup in a directory. We make use of bulk lookup to query a slew of
597 * files in one go and create inodes for them. The inode of the file we were
598 * asked for is returned.
600 static struct inode
*afs_do_lookup(struct inode
*dir
, struct dentry
*dentry
,
603 struct afs_lookup_cookie
*cookie
;
604 struct afs_cb_interest
*cbi
= NULL
;
605 struct afs_super_info
*as
= dir
->i_sb
->s_fs_info
;
606 struct afs_iget_data data
;
607 struct afs_fs_cursor fc
;
608 struct afs_vnode
*dvnode
= AFS_FS_I(dir
);
609 struct inode
*inode
= NULL
;
612 _enter("{%lu},%p{%pd},", dir
->i_ino
, dentry
, dentry
);
614 cookie
= kzalloc(sizeof(struct afs_lookup_cookie
), GFP_KERNEL
);
616 return ERR_PTR(-ENOMEM
);
618 cookie
->ctx
.actor
= afs_lookup_filldir
;
619 cookie
->name
= dentry
->d_name
;
620 cookie
->nr_fids
= 1; /* slot 0 is saved for the fid we actually want */
622 read_seqlock_excl(&dvnode
->cb_lock
);
623 if (dvnode
->cb_interest
&&
624 dvnode
->cb_interest
->server
&&
625 test_bit(AFS_SERVER_FL_NO_IBULK
, &dvnode
->cb_interest
->server
->flags
))
626 cookie
->one_only
= true;
627 read_sequnlock_excl(&dvnode
->cb_lock
);
629 for (i
= 0; i
< 50; i
++)
630 cookie
->fids
[i
].vid
= as
->volume
->vid
;
632 /* search the directory */
633 ret
= afs_dir_iterate(dir
, &cookie
->ctx
, key
);
635 inode
= ERR_PTR(ret
);
639 inode
= ERR_PTR(-ENOENT
);
643 /* Check to see if we already have an inode for the primary fid. */
644 data
.volume
= dvnode
->volume
;
645 data
.fid
= cookie
->fids
[0];
646 inode
= ilookup5(dir
->i_sb
, cookie
->fids
[0].vnode
, afs_iget5_test
, &data
);
650 /* Need space for examining all the selected files */
651 inode
= ERR_PTR(-ENOMEM
);
652 cookie
->statuses
= kcalloc(cookie
->nr_fids
, sizeof(struct afs_file_status
),
654 if (!cookie
->statuses
)
657 cookie
->callbacks
= kcalloc(cookie
->nr_fids
, sizeof(struct afs_callback
),
659 if (!cookie
->callbacks
)
662 /* Try FS.InlineBulkStatus first. Abort codes for the individual
663 * lookups contained therein are stored in the reply without aborting
664 * the whole operation.
666 if (cookie
->one_only
)
667 goto no_inline_bulk_status
;
669 inode
= ERR_PTR(-ERESTARTSYS
);
670 if (afs_begin_vnode_operation(&fc
, dvnode
, key
)) {
671 while (afs_select_fileserver(&fc
)) {
672 if (test_bit(AFS_SERVER_FL_NO_IBULK
,
673 &fc
.cbi
->server
->flags
)) {
674 fc
.ac
.abort_code
= RX_INVALID_OPERATION
;
675 fc
.ac
.error
= -ECONNABORTED
;
678 afs_fs_inline_bulk_status(&fc
,
683 cookie
->nr_fids
, NULL
);
686 if (fc
.ac
.error
== 0)
687 cbi
= afs_get_cb_interest(fc
.cbi
);
688 if (fc
.ac
.abort_code
== RX_INVALID_OPERATION
)
689 set_bit(AFS_SERVER_FL_NO_IBULK
, &fc
.cbi
->server
->flags
);
690 inode
= ERR_PTR(afs_end_vnode_operation(&fc
));
695 if (fc
.ac
.abort_code
!= RX_INVALID_OPERATION
)
698 no_inline_bulk_status
:
699 /* We could try FS.BulkStatus next, but this aborts the entire op if
700 * any of the lookups fails - so, for the moment, revert to
701 * FS.FetchStatus for just the primary fid.
704 inode
= ERR_PTR(-ERESTARTSYS
);
705 if (afs_begin_vnode_operation(&fc
, dvnode
, key
)) {
706 while (afs_select_fileserver(&fc
)) {
707 afs_fs_fetch_status(&fc
,
715 if (fc
.ac
.error
== 0)
716 cbi
= afs_get_cb_interest(fc
.cbi
);
717 inode
= ERR_PTR(afs_end_vnode_operation(&fc
));
723 for (i
= 0; i
< cookie
->nr_fids
; i
++)
724 cookie
->statuses
[i
].abort_code
= 0;
727 /* Turn all the files into inodes and save the first one - which is the
728 * one we actually want.
730 if (cookie
->statuses
[0].abort_code
!= 0)
731 inode
= ERR_PTR(afs_abort_to_error(cookie
->statuses
[0].abort_code
));
733 for (i
= 0; i
< cookie
->nr_fids
; i
++) {
736 if (cookie
->statuses
[i
].abort_code
!= 0)
739 ti
= afs_iget(dir
->i_sb
, key
, &cookie
->fids
[i
],
740 &cookie
->statuses
[i
],
741 &cookie
->callbacks
[i
],
752 afs_put_cb_interest(afs_v2net(dvnode
), cbi
);
753 kfree(cookie
->callbacks
);
755 kfree(cookie
->statuses
);
762 * Look up an entry in a directory with @sys substitution.
764 static struct dentry
*afs_lookup_atsys(struct inode
*dir
, struct dentry
*dentry
,
767 struct afs_sysnames
*subs
;
768 struct afs_net
*net
= afs_i2net(dir
);
770 char *buf
, *p
, *name
;
775 ret
= ERR_PTR(-ENOMEM
);
776 p
= buf
= kmalloc(AFSNAMEMAX
, GFP_KERNEL
);
779 if (dentry
->d_name
.len
> 4) {
780 memcpy(p
, dentry
->d_name
.name
, dentry
->d_name
.len
- 4);
781 p
+= dentry
->d_name
.len
- 4;
784 /* There is an ordered list of substitutes that we have to try. */
785 read_lock(&net
->sysnames_lock
);
786 subs
= net
->sysnames
;
787 refcount_inc(&subs
->usage
);
788 read_unlock(&net
->sysnames_lock
);
790 for (i
= 0; i
< subs
->nr
; i
++) {
791 name
= subs
->subs
[i
];
792 len
= dentry
->d_name
.len
- 4 + strlen(name
);
793 if (len
>= AFSNAMEMAX
) {
794 ret
= ERR_PTR(-ENAMETOOLONG
);
799 ret
= lookup_one_len(buf
, dentry
->d_parent
, len
);
800 if (IS_ERR(ret
) || d_is_positive(ret
))
805 /* We don't want to d_add() the @sys dentry here as we don't want to
806 * the cached dentry to hide changes to the sysnames list.
810 afs_put_sysnames(subs
);
818 * look up an entry in a directory
820 static struct dentry
*afs_lookup(struct inode
*dir
, struct dentry
*dentry
,
823 struct afs_vnode
*dvnode
= AFS_FS_I(dir
);
829 _enter("{%x:%u},%p{%pd},",
830 dvnode
->fid
.vid
, dvnode
->fid
.vnode
, dentry
, dentry
);
832 ASSERTCMP(d_inode(dentry
), ==, NULL
);
834 if (dentry
->d_name
.len
>= AFSNAMEMAX
) {
835 _leave(" = -ENAMETOOLONG");
836 return ERR_PTR(-ENAMETOOLONG
);
839 if (test_bit(AFS_VNODE_DELETED
, &dvnode
->flags
)) {
840 _leave(" = -ESTALE");
841 return ERR_PTR(-ESTALE
);
844 key
= afs_request_key(dvnode
->volume
->cell
);
846 _leave(" = %ld [key]", PTR_ERR(key
));
847 return ERR_CAST(key
);
850 ret
= afs_validate(dvnode
, key
);
853 _leave(" = %d [val]", ret
);
857 if (dentry
->d_name
.len
>= 4 &&
858 dentry
->d_name
.name
[dentry
->d_name
.len
- 4] == '@' &&
859 dentry
->d_name
.name
[dentry
->d_name
.len
- 3] == 's' &&
860 dentry
->d_name
.name
[dentry
->d_name
.len
- 2] == 'y' &&
861 dentry
->d_name
.name
[dentry
->d_name
.len
- 1] == 's')
862 return afs_lookup_atsys(dir
, dentry
, key
);
864 afs_stat_v(dvnode
, n_lookup
);
865 inode
= afs_do_lookup(dir
, dentry
, key
);
867 if (inode
== ERR_PTR(-ENOENT
)) {
868 inode
= afs_try_auto_mntpt(dentry
, dir
);
871 (void *)(unsigned long)dvnode
->status
.data_version
;
873 d
= d_splice_alias(inode
, dentry
);
874 if (!IS_ERR_OR_NULL(d
))
875 d
->d_fsdata
= dentry
->d_fsdata
;
880 * check that a dentry lookup hit has found a valid entry
881 * - NOTE! the hit can be a negative hit too, so we can't assume we have an
884 static int afs_d_revalidate(struct dentry
*dentry
, unsigned int flags
)
886 struct afs_vnode
*vnode
, *dir
;
887 struct afs_fid
uninitialized_var(fid
);
888 struct dentry
*parent
;
891 long dir_version
, de_version
;
894 if (flags
& LOOKUP_RCU
)
897 if (d_really_is_positive(dentry
)) {
898 vnode
= AFS_FS_I(d_inode(dentry
));
899 _enter("{v={%x:%u} n=%pd fl=%lx},",
900 vnode
->fid
.vid
, vnode
->fid
.vnode
, dentry
,
903 _enter("{neg n=%pd}", dentry
);
906 key
= afs_request_key(AFS_FS_S(dentry
->d_sb
)->volume
->cell
);
910 if (d_really_is_positive(dentry
)) {
911 inode
= d_inode(dentry
);
913 vnode
= AFS_FS_I(inode
);
914 afs_validate(vnode
, key
);
915 if (test_bit(AFS_VNODE_DELETED
, &vnode
->flags
))
920 /* lock down the parent dentry so we can peer at it */
921 parent
= dget_parent(dentry
);
922 dir
= AFS_FS_I(d_inode(parent
));
924 /* validate the parent directory */
925 afs_validate(dir
, key
);
927 if (test_bit(AFS_VNODE_DELETED
, &dir
->flags
)) {
928 _debug("%pd: parent dir deleted", dentry
);
932 /* We only need to invalidate a dentry if the server's copy changed
933 * behind our back. If we made the change, it's no problem. Note that
934 * on a 32-bit system, we only have 32 bits in the dentry to store the
937 dir_version
= (long)dir
->status
.data_version
;
938 de_version
= (long)dentry
->d_fsdata
;
939 if (de_version
== dir_version
)
942 dir_version
= (long)dir
->invalid_before
;
943 if (de_version
- dir_version
>= 0)
946 _debug("dir modified");
947 afs_stat_v(dir
, n_reval
);
949 /* search the directory for this vnode */
950 ret
= afs_do_lookup_one(&dir
->vfs_inode
, dentry
, &fid
, key
);
953 /* the filename maps to something */
954 if (d_really_is_negative(dentry
))
956 inode
= d_inode(dentry
);
957 if (is_bad_inode(inode
)) {
958 printk("kAFS: afs_d_revalidate: %pd2 has bad inode\n",
963 vnode
= AFS_FS_I(inode
);
965 /* if the vnode ID has changed, then the dirent points to a
967 if (fid
.vnode
!= vnode
->fid
.vnode
) {
968 _debug("%pd: dirent changed [%u != %u]",
974 /* if the vnode ID uniqifier has changed, then the file has
975 * been deleted and replaced, and the original vnode ID has
977 if (fid
.unique
!= vnode
->fid
.unique
) {
978 _debug("%pd: file deleted (uq %u -> %u I:%u)",
981 vnode
->vfs_inode
.i_generation
);
982 write_seqlock(&vnode
->cb_lock
);
983 set_bit(AFS_VNODE_DELETED
, &vnode
->flags
);
984 write_sequnlock(&vnode
->cb_lock
);
990 /* the filename is unknown */
991 _debug("%pd: dirent not found", dentry
);
992 if (d_really_is_positive(dentry
))
997 _debug("failed to iterate dir %pd: %d",
1003 dentry
->d_fsdata
= (void *)dir_version
;
1006 _leave(" = 1 [valid]");
1009 /* the dirent, if it exists, now points to a different vnode */
1011 spin_lock(&dentry
->d_lock
);
1012 dentry
->d_flags
|= DCACHE_NFSFS_RENAMED
;
1013 spin_unlock(&dentry
->d_lock
);
1016 _debug("dropping dentry %pd2", dentry
);
1021 _leave(" = 0 [bad]");
1026 * allow the VFS to enquire as to whether a dentry should be unhashed (mustn't
1028 * - called from dput() when d_count is going to 0.
1029 * - return 1 to request dentry be unhashed, 0 otherwise
1031 static int afs_d_delete(const struct dentry
*dentry
)
1033 _enter("%pd", dentry
);
1035 if (dentry
->d_flags
& DCACHE_NFSFS_RENAMED
)
1038 if (d_really_is_positive(dentry
) &&
1039 (test_bit(AFS_VNODE_DELETED
, &AFS_FS_I(d_inode(dentry
))->flags
) ||
1040 test_bit(AFS_VNODE_PSEUDODIR
, &AFS_FS_I(d_inode(dentry
))->flags
)))
1043 _leave(" = 0 [keep]");
1047 _leave(" = 1 [zap]");
1052 * handle dentry release
1054 void afs_d_release(struct dentry
*dentry
)
1056 _enter("%pd", dentry
);
1060 * Create a new inode for create/mkdir/symlink
1062 static void afs_vnode_new_inode(struct afs_fs_cursor
*fc
,
1063 struct dentry
*new_dentry
,
1064 struct afs_fid
*newfid
,
1065 struct afs_file_status
*newstatus
,
1066 struct afs_callback
*newcb
)
1068 struct afs_vnode
*vnode
;
1069 struct inode
*inode
;
1071 if (fc
->ac
.error
< 0)
1076 inode
= afs_iget(fc
->vnode
->vfs_inode
.i_sb
, fc
->key
,
1077 newfid
, newstatus
, newcb
, fc
->cbi
);
1078 if (IS_ERR(inode
)) {
1079 /* ENOMEM or EINTR at a really inconvenient time - just abandon
1080 * the new directory on the server.
1082 fc
->ac
.error
= PTR_ERR(inode
);
1086 vnode
= AFS_FS_I(inode
);
1087 set_bit(AFS_VNODE_NEW_CONTENT
, &vnode
->flags
);
1088 d_add(new_dentry
, inode
);
1092 * create a directory on an AFS filesystem
1094 static int afs_mkdir(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
)
1096 struct afs_file_status newstatus
;
1097 struct afs_fs_cursor fc
;
1098 struct afs_callback newcb
;
1099 struct afs_vnode
*dvnode
= AFS_FS_I(dir
);
1100 struct afs_fid newfid
;
1102 u64 data_version
= dvnode
->status
.data_version
;
1107 _enter("{%x:%u},{%pd},%ho",
1108 dvnode
->fid
.vid
, dvnode
->fid
.vnode
, dentry
, mode
);
1110 key
= afs_request_key(dvnode
->volume
->cell
);
1117 if (afs_begin_vnode_operation(&fc
, dvnode
, key
)) {
1118 while (afs_select_fileserver(&fc
)) {
1119 fc
.cb_break
= afs_calc_vnode_cb_break(dvnode
);
1120 afs_fs_create(&fc
, dentry
->d_name
.name
, mode
, data_version
,
1121 &newfid
, &newstatus
, &newcb
);
1124 afs_check_for_remote_deletion(&fc
, fc
.vnode
);
1125 afs_vnode_commit_status(&fc
, dvnode
, fc
.cb_break
);
1126 afs_vnode_new_inode(&fc
, dentry
, &newfid
, &newstatus
, &newcb
);
1127 ret
= afs_end_vnode_operation(&fc
);
1135 test_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
))
1136 afs_edit_dir_add(dvnode
, &dentry
->d_name
, &newfid
,
1137 afs_edit_dir_for_create
);
1147 _leave(" = %d", ret
);
1152 * Remove a subdir from a directory.
1154 static void afs_dir_remove_subdir(struct dentry
*dentry
)
1156 if (d_really_is_positive(dentry
)) {
1157 struct afs_vnode
*vnode
= AFS_FS_I(d_inode(dentry
));
1159 clear_nlink(&vnode
->vfs_inode
);
1160 set_bit(AFS_VNODE_DELETED
, &vnode
->flags
);
1161 clear_bit(AFS_VNODE_CB_PROMISED
, &vnode
->flags
);
1162 clear_bit(AFS_VNODE_DIR_VALID
, &vnode
->flags
);
1167 * remove a directory from an AFS filesystem
1169 static int afs_rmdir(struct inode
*dir
, struct dentry
*dentry
)
1171 struct afs_fs_cursor fc
;
1172 struct afs_vnode
*dvnode
= AFS_FS_I(dir
);
1174 u64 data_version
= dvnode
->status
.data_version
;
1177 _enter("{%x:%u},{%pd}",
1178 dvnode
->fid
.vid
, dvnode
->fid
.vnode
, dentry
);
1180 key
= afs_request_key(dvnode
->volume
->cell
);
1187 if (afs_begin_vnode_operation(&fc
, dvnode
, key
)) {
1188 while (afs_select_fileserver(&fc
)) {
1189 fc
.cb_break
= afs_calc_vnode_cb_break(dvnode
);
1190 afs_fs_remove(&fc
, dentry
->d_name
.name
, true,
1194 afs_vnode_commit_status(&fc
, dvnode
, fc
.cb_break
);
1195 ret
= afs_end_vnode_operation(&fc
);
1197 afs_dir_remove_subdir(dentry
);
1198 if (test_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
))
1199 afs_edit_dir_remove(dvnode
, &dentry
->d_name
,
1200 afs_edit_dir_for_rmdir
);
1210 * Remove a link to a file or symlink from a directory.
1212 * If the file was not deleted due to excess hard links, the fileserver will
1213 * break the callback promise on the file - if it had one - before it returns
1214 * to us, and if it was deleted, it won't
1216 * However, if we didn't have a callback promise outstanding, or it was
1217 * outstanding on a different server, then it won't break it either...
1219 static int afs_dir_remove_link(struct dentry
*dentry
, struct key
*key
,
1220 unsigned long d_version_before
,
1221 unsigned long d_version_after
)
1226 /* There were no intervening changes on the server if the version
1227 * number we got back was incremented by exactly 1.
1229 dir_valid
= (d_version_after
== d_version_before
+ 1);
1231 if (d_really_is_positive(dentry
)) {
1232 struct afs_vnode
*vnode
= AFS_FS_I(d_inode(dentry
));
1235 drop_nlink(&vnode
->vfs_inode
);
1236 if (vnode
->vfs_inode
.i_nlink
== 0) {
1237 set_bit(AFS_VNODE_DELETED
, &vnode
->flags
);
1238 clear_bit(AFS_VNODE_CB_PROMISED
, &vnode
->flags
);
1242 clear_bit(AFS_VNODE_CB_PROMISED
, &vnode
->flags
);
1244 if (test_bit(AFS_VNODE_DELETED
, &vnode
->flags
))
1245 kdebug("AFS_VNODE_DELETED");
1247 ret
= afs_validate(vnode
, key
);
1251 _debug("nlink %d [val %d]", vnode
->vfs_inode
.i_nlink
, ret
);
1258 * Remove a file or symlink from an AFS filesystem.
1260 static int afs_unlink(struct inode
*dir
, struct dentry
*dentry
)
1262 struct afs_fs_cursor fc
;
1263 struct afs_vnode
*dvnode
= AFS_FS_I(dir
), *vnode
;
1265 unsigned long d_version
= (unsigned long)dentry
->d_fsdata
;
1266 u64 data_version
= dvnode
->status
.data_version
;
1269 _enter("{%x:%u},{%pd}",
1270 dvnode
->fid
.vid
, dvnode
->fid
.vnode
, dentry
);
1272 if (dentry
->d_name
.len
>= AFSNAMEMAX
)
1273 return -ENAMETOOLONG
;
1275 key
= afs_request_key(dvnode
->volume
->cell
);
1281 /* Try to make sure we have a callback promise on the victim. */
1282 if (d_really_is_positive(dentry
)) {
1283 vnode
= AFS_FS_I(d_inode(dentry
));
1284 ret
= afs_validate(vnode
, key
);
1290 if (afs_begin_vnode_operation(&fc
, dvnode
, key
)) {
1291 while (afs_select_fileserver(&fc
)) {
1292 fc
.cb_break
= afs_calc_vnode_cb_break(dvnode
);
1293 afs_fs_remove(&fc
, dentry
->d_name
.name
, false,
1297 afs_vnode_commit_status(&fc
, dvnode
, fc
.cb_break
);
1298 ret
= afs_end_vnode_operation(&fc
);
1300 ret
= afs_dir_remove_link(
1301 dentry
, key
, d_version
,
1302 (unsigned long)dvnode
->status
.data_version
);
1304 test_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
))
1305 afs_edit_dir_remove(dvnode
, &dentry
->d_name
,
1306 afs_edit_dir_for_unlink
);
1312 _leave(" = %d", ret
);
1317 * create a regular file on an AFS filesystem
1319 static int afs_create(struct inode
*dir
, struct dentry
*dentry
, umode_t mode
,
1322 struct afs_fs_cursor fc
;
1323 struct afs_file_status newstatus
;
1324 struct afs_callback newcb
;
1325 struct afs_vnode
*dvnode
= AFS_FS_I(dir
);
1326 struct afs_fid newfid
;
1328 u64 data_version
= dvnode
->status
.data_version
;
1333 _enter("{%x:%u},{%pd},%ho,",
1334 dvnode
->fid
.vid
, dvnode
->fid
.vnode
, dentry
, mode
);
1336 ret
= -ENAMETOOLONG
;
1337 if (dentry
->d_name
.len
>= AFSNAMEMAX
)
1340 key
= afs_request_key(dvnode
->volume
->cell
);
1347 if (afs_begin_vnode_operation(&fc
, dvnode
, key
)) {
1348 while (afs_select_fileserver(&fc
)) {
1349 fc
.cb_break
= afs_calc_vnode_cb_break(dvnode
);
1350 afs_fs_create(&fc
, dentry
->d_name
.name
, mode
, data_version
,
1351 &newfid
, &newstatus
, &newcb
);
1354 afs_check_for_remote_deletion(&fc
, fc
.vnode
);
1355 afs_vnode_commit_status(&fc
, dvnode
, fc
.cb_break
);
1356 afs_vnode_new_inode(&fc
, dentry
, &newfid
, &newstatus
, &newcb
);
1357 ret
= afs_end_vnode_operation(&fc
);
1364 if (test_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
))
1365 afs_edit_dir_add(dvnode
, &dentry
->d_name
, &newfid
,
1366 afs_edit_dir_for_create
);
1376 _leave(" = %d", ret
);
1381 * create a hard link between files in an AFS filesystem
1383 static int afs_link(struct dentry
*from
, struct inode
*dir
,
1384 struct dentry
*dentry
)
1386 struct afs_fs_cursor fc
;
1387 struct afs_vnode
*dvnode
, *vnode
;
1392 vnode
= AFS_FS_I(d_inode(from
));
1393 dvnode
= AFS_FS_I(dir
);
1394 data_version
= dvnode
->status
.data_version
;
1396 _enter("{%x:%u},{%x:%u},{%pd}",
1397 vnode
->fid
.vid
, vnode
->fid
.vnode
,
1398 dvnode
->fid
.vid
, dvnode
->fid
.vnode
,
1401 ret
= -ENAMETOOLONG
;
1402 if (dentry
->d_name
.len
>= AFSNAMEMAX
)
1405 key
= afs_request_key(dvnode
->volume
->cell
);
1412 if (afs_begin_vnode_operation(&fc
, dvnode
, key
)) {
1413 if (mutex_lock_interruptible_nested(&vnode
->io_lock
, 1) < 0) {
1414 afs_end_vnode_operation(&fc
);
1418 while (afs_select_fileserver(&fc
)) {
1419 fc
.cb_break
= afs_calc_vnode_cb_break(dvnode
);
1420 fc
.cb_break_2
= afs_calc_vnode_cb_break(vnode
);
1421 afs_fs_link(&fc
, vnode
, dentry
->d_name
.name
, data_version
);
1424 afs_vnode_commit_status(&fc
, dvnode
, fc
.cb_break
);
1425 afs_vnode_commit_status(&fc
, vnode
, fc
.cb_break_2
);
1426 ihold(&vnode
->vfs_inode
);
1427 d_instantiate(dentry
, &vnode
->vfs_inode
);
1429 mutex_unlock(&vnode
->io_lock
);
1430 ret
= afs_end_vnode_operation(&fc
);
1437 if (test_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
))
1438 afs_edit_dir_add(dvnode
, &dentry
->d_name
, &vnode
->fid
,
1439 afs_edit_dir_for_link
);
1449 _leave(" = %d", ret
);
1454 * create a symlink in an AFS filesystem
1456 static int afs_symlink(struct inode
*dir
, struct dentry
*dentry
,
1457 const char *content
)
1459 struct afs_fs_cursor fc
;
1460 struct afs_file_status newstatus
;
1461 struct afs_vnode
*dvnode
= AFS_FS_I(dir
);
1462 struct afs_fid newfid
;
1464 u64 data_version
= dvnode
->status
.data_version
;
1467 _enter("{%x:%u},{%pd},%s",
1468 dvnode
->fid
.vid
, dvnode
->fid
.vnode
, dentry
,
1471 ret
= -ENAMETOOLONG
;
1472 if (dentry
->d_name
.len
>= AFSNAMEMAX
)
1476 if (strlen(content
) >= AFSPATHMAX
)
1479 key
= afs_request_key(dvnode
->volume
->cell
);
1486 if (afs_begin_vnode_operation(&fc
, dvnode
, key
)) {
1487 while (afs_select_fileserver(&fc
)) {
1488 fc
.cb_break
= afs_calc_vnode_cb_break(dvnode
);
1489 afs_fs_symlink(&fc
, dentry
->d_name
.name
,
1490 content
, data_version
,
1491 &newfid
, &newstatus
);
1494 afs_check_for_remote_deletion(&fc
, fc
.vnode
);
1495 afs_vnode_commit_status(&fc
, dvnode
, fc
.cb_break
);
1496 afs_vnode_new_inode(&fc
, dentry
, &newfid
, &newstatus
, NULL
);
1497 ret
= afs_end_vnode_operation(&fc
);
1504 if (test_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
))
1505 afs_edit_dir_add(dvnode
, &dentry
->d_name
, &newfid
,
1506 afs_edit_dir_for_symlink
);
1516 _leave(" = %d", ret
);
1521 * rename a file in an AFS filesystem and/or move it between directories
1523 static int afs_rename(struct inode
*old_dir
, struct dentry
*old_dentry
,
1524 struct inode
*new_dir
, struct dentry
*new_dentry
,
1527 struct afs_fs_cursor fc
;
1528 struct afs_vnode
*orig_dvnode
, *new_dvnode
, *vnode
;
1530 u64 orig_data_version
, new_data_version
;
1531 bool new_negative
= d_is_negative(new_dentry
);
1537 vnode
= AFS_FS_I(d_inode(old_dentry
));
1538 orig_dvnode
= AFS_FS_I(old_dir
);
1539 new_dvnode
= AFS_FS_I(new_dir
);
1540 orig_data_version
= orig_dvnode
->status
.data_version
;
1541 new_data_version
= new_dvnode
->status
.data_version
;
1543 _enter("{%x:%u},{%x:%u},{%x:%u},{%pd}",
1544 orig_dvnode
->fid
.vid
, orig_dvnode
->fid
.vnode
,
1545 vnode
->fid
.vid
, vnode
->fid
.vnode
,
1546 new_dvnode
->fid
.vid
, new_dvnode
->fid
.vnode
,
1549 key
= afs_request_key(orig_dvnode
->volume
->cell
);
1556 if (afs_begin_vnode_operation(&fc
, orig_dvnode
, key
)) {
1557 if (orig_dvnode
!= new_dvnode
) {
1558 if (mutex_lock_interruptible_nested(&new_dvnode
->io_lock
, 1) < 0) {
1559 afs_end_vnode_operation(&fc
);
1563 while (afs_select_fileserver(&fc
)) {
1564 fc
.cb_break
= afs_calc_vnode_cb_break(orig_dvnode
);
1565 fc
.cb_break_2
= afs_calc_vnode_cb_break(new_dvnode
);
1566 afs_fs_rename(&fc
, old_dentry
->d_name
.name
,
1567 new_dvnode
, new_dentry
->d_name
.name
,
1568 orig_data_version
, new_data_version
);
1571 afs_vnode_commit_status(&fc
, orig_dvnode
, fc
.cb_break
);
1572 afs_vnode_commit_status(&fc
, new_dvnode
, fc
.cb_break_2
);
1573 if (orig_dvnode
!= new_dvnode
)
1574 mutex_unlock(&new_dvnode
->io_lock
);
1575 ret
= afs_end_vnode_operation(&fc
);
1581 if (test_bit(AFS_VNODE_DIR_VALID
, &orig_dvnode
->flags
))
1582 afs_edit_dir_remove(orig_dvnode
, &old_dentry
->d_name
,
1583 afs_edit_dir_for_rename
);
1585 if (!new_negative
&&
1586 test_bit(AFS_VNODE_DIR_VALID
, &new_dvnode
->flags
))
1587 afs_edit_dir_remove(new_dvnode
, &new_dentry
->d_name
,
1588 afs_edit_dir_for_rename
);
1590 if (test_bit(AFS_VNODE_DIR_VALID
, &new_dvnode
->flags
))
1591 afs_edit_dir_add(new_dvnode
, &new_dentry
->d_name
,
1592 &vnode
->fid
, afs_edit_dir_for_rename
);
1598 _leave(" = %d", ret
);
1603 * Release a directory page and clean up its private state if it's not busy
1604 * - return true if the page can now be released, false if not
1606 static int afs_dir_releasepage(struct page
*page
, gfp_t gfp_flags
)
1608 struct afs_vnode
*dvnode
= AFS_FS_I(page
->mapping
->host
);
1610 _enter("{{%x:%u}[%lu]}", dvnode
->fid
.vid
, dvnode
->fid
.vnode
, page
->index
);
1612 set_page_private(page
, 0);
1613 ClearPagePrivate(page
);
1615 /* The directory will need reloading. */
1616 if (test_and_clear_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
))
1617 afs_stat_v(dvnode
, n_relpg
);
1622 * invalidate part or all of a page
1623 * - release a page and clean up its private data if offset is 0 (indicating
1626 static void afs_dir_invalidatepage(struct page
*page
, unsigned int offset
,
1627 unsigned int length
)
1629 struct afs_vnode
*dvnode
= AFS_FS_I(page
->mapping
->host
);
1631 _enter("{%lu},%u,%u", page
->index
, offset
, length
);
1633 BUG_ON(!PageLocked(page
));
1635 /* The directory will need reloading. */
1636 if (test_and_clear_bit(AFS_VNODE_DIR_VALID
, &dvnode
->flags
))
1637 afs_stat_v(dvnode
, n_inval
);
1639 /* we clean up only if the entire page is being invalidated */
1640 if (offset
== 0 && length
== PAGE_SIZE
) {
1641 set_page_private(page
, 0);
1642 ClearPagePrivate(page
);