1 /* AFS vnode management
3 * Copyright (C) 2002, 2007 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>
13 #include <linux/module.h>
14 #include <linux/init.h>
16 #include <linux/sched.h>
20 static noinline
bool dump_tree_aux(struct rb_node
*node
, struct rb_node
*parent
,
23 struct afs_vnode
*vnode
;
30 bad
= dump_tree_aux(node
->rb_left
, node
, depth
+ 2, '/');
32 vnode
= rb_entry(node
, struct afs_vnode
, cb_promise
);
33 _debug("%c %*.*s%c%p {%d}",
34 rb_is_red(node
) ? 'R' : 'B',
36 vnode
, vnode
->cb_expires_at
);
37 if (rb_parent(node
) != parent
) {
38 printk("BAD: %p != %p\n", rb_parent(node
), parent
);
43 bad
|= dump_tree_aux(node
->rb_right
, node
, depth
+ 2, '\\');
48 static noinline
void dump_tree(const char *name
, struct afs_server
*server
)
51 if (dump_tree_aux(server
->cb_promises
.rb_node
, NULL
, 0, '-'))
57 * insert a vnode into the backing server's vnode tree
59 static void afs_install_vnode(struct afs_vnode
*vnode
,
60 struct afs_server
*server
)
62 struct afs_server
*old_server
= vnode
->server
;
63 struct afs_vnode
*xvnode
;
64 struct rb_node
*parent
, **p
;
66 _enter("%p,%p", vnode
, server
);
69 spin_lock(&old_server
->fs_lock
);
70 rb_erase(&vnode
->server_rb
, &old_server
->fs_vnodes
);
71 spin_unlock(&old_server
->fs_lock
);
74 afs_get_server(server
);
75 vnode
->server
= server
;
76 afs_put_server(old_server
);
78 /* insert into the server's vnode tree in FID order */
79 spin_lock(&server
->fs_lock
);
82 p
= &server
->fs_vnodes
.rb_node
;
85 xvnode
= rb_entry(parent
, struct afs_vnode
, server_rb
);
86 if (vnode
->fid
.vid
< xvnode
->fid
.vid
)
88 else if (vnode
->fid
.vid
> xvnode
->fid
.vid
)
90 else if (vnode
->fid
.vnode
< xvnode
->fid
.vnode
)
92 else if (vnode
->fid
.vnode
> xvnode
->fid
.vnode
)
94 else if (vnode
->fid
.unique
< xvnode
->fid
.unique
)
96 else if (vnode
->fid
.unique
> xvnode
->fid
.unique
)
99 BUG(); /* can't happen unless afs_iget() malfunctions */
102 rb_link_node(&vnode
->server_rb
, parent
, p
);
103 rb_insert_color(&vnode
->server_rb
, &server
->fs_vnodes
);
105 spin_unlock(&server
->fs_lock
);
110 * insert a vnode into the promising server's update/expiration tree
111 * - caller must hold vnode->lock
113 static void afs_vnode_note_promise(struct afs_vnode
*vnode
,
114 struct afs_server
*server
)
116 struct afs_server
*old_server
;
117 struct afs_vnode
*xvnode
;
118 struct rb_node
*parent
, **p
;
120 _enter("%p,%p", vnode
, server
);
122 ASSERT(server
!= NULL
);
124 old_server
= vnode
->server
;
125 if (vnode
->cb_promised
) {
126 if (server
== old_server
&&
127 vnode
->cb_expires
== vnode
->cb_expires_at
) {
128 _leave(" [no change]");
132 spin_lock(&old_server
->cb_lock
);
133 if (vnode
->cb_promised
) {
135 rb_erase(&vnode
->cb_promise
, &old_server
->cb_promises
);
136 vnode
->cb_promised
= false;
138 spin_unlock(&old_server
->cb_lock
);
141 if (vnode
->server
!= server
)
142 afs_install_vnode(vnode
, server
);
144 vnode
->cb_expires_at
= vnode
->cb_expires
;
145 _debug("PROMISE on %p {%lu}",
146 vnode
, (unsigned long) vnode
->cb_expires_at
);
148 /* abuse an RB-tree to hold the expiration order (we may have multiple
149 * items with the same expiration time) */
150 spin_lock(&server
->cb_lock
);
153 p
= &server
->cb_promises
.rb_node
;
156 xvnode
= rb_entry(parent
, struct afs_vnode
, cb_promise
);
157 if (vnode
->cb_expires_at
< xvnode
->cb_expires_at
)
163 rb_link_node(&vnode
->cb_promise
, parent
, p
);
164 rb_insert_color(&vnode
->cb_promise
, &server
->cb_promises
);
165 vnode
->cb_promised
= true;
167 spin_unlock(&server
->cb_lock
);
172 * handle remote file deletion by discarding the callback promise
174 static void afs_vnode_deleted_remotely(struct afs_vnode
*vnode
)
176 struct afs_server
*server
;
178 _enter("{%p}", vnode
->server
);
180 set_bit(AFS_VNODE_DELETED
, &vnode
->flags
);
182 server
= vnode
->server
;
184 if (vnode
->cb_promised
) {
185 spin_lock(&server
->cb_lock
);
186 if (vnode
->cb_promised
) {
187 rb_erase(&vnode
->cb_promise
,
188 &server
->cb_promises
);
189 vnode
->cb_promised
= false;
191 spin_unlock(&server
->cb_lock
);
194 spin_lock(&server
->fs_lock
);
195 rb_erase(&vnode
->server_rb
, &server
->fs_vnodes
);
196 spin_unlock(&server
->fs_lock
);
198 vnode
->server
= NULL
;
199 afs_put_server(server
);
201 ASSERT(!vnode
->cb_promised
);
208 * finish off updating the recorded status of a file after a successful
209 * operation completion
210 * - starts callback expiry timer
211 * - adds to server's callback list
213 void afs_vnode_finalise_status_update(struct afs_vnode
*vnode
,
214 struct afs_server
*server
)
216 struct afs_server
*oldserver
= NULL
;
218 _enter("%p,%p", vnode
, server
);
220 spin_lock(&vnode
->lock
);
221 clear_bit(AFS_VNODE_CB_BROKEN
, &vnode
->flags
);
222 afs_vnode_note_promise(vnode
, server
);
224 ASSERTCMP(vnode
->update_cnt
, >=, 0);
225 spin_unlock(&vnode
->lock
);
227 wake_up_all(&vnode
->update_waitq
);
228 afs_put_server(oldserver
);
233 * finish off updating the recorded status of a file after an operation failed
235 static void afs_vnode_status_update_failed(struct afs_vnode
*vnode
, int ret
)
237 _enter("{%x:%u},%d", vnode
->fid
.vid
, vnode
->fid
.vnode
, ret
);
239 spin_lock(&vnode
->lock
);
241 clear_bit(AFS_VNODE_CB_BROKEN
, &vnode
->flags
);
243 if (ret
== -ENOENT
) {
244 /* the file was deleted on the server */
245 _debug("got NOENT from server - marking file deleted");
246 afs_vnode_deleted_remotely(vnode
);
250 ASSERTCMP(vnode
->update_cnt
, >=, 0);
251 spin_unlock(&vnode
->lock
);
253 wake_up_all(&vnode
->update_waitq
);
258 * fetch file status from the volume
259 * - don't issue a fetch if:
260 * - the changed bit is not set and there's a valid callback
261 * - there are any outstanding ops that will fetch the status
262 * - TODO implement local caching
264 int afs_vnode_fetch_status(struct afs_vnode
*vnode
,
265 struct afs_vnode
*auth_vnode
, struct key
*key
)
267 struct afs_server
*server
;
268 unsigned long acl_order
;
271 DECLARE_WAITQUEUE(myself
, current
);
273 _enter("%s,{%x:%u.%u}",
274 vnode
->volume
->vlocation
->vldb
.name
,
275 vnode
->fid
.vid
, vnode
->fid
.vnode
, vnode
->fid
.unique
);
277 if (!test_bit(AFS_VNODE_CB_BROKEN
, &vnode
->flags
) &&
278 vnode
->cb_promised
) {
279 _leave(" [unchanged]");
283 if (test_bit(AFS_VNODE_DELETED
, &vnode
->flags
)) {
284 _leave(" [deleted]");
290 acl_order
= auth_vnode
->acl_order
;
292 spin_lock(&vnode
->lock
);
294 if (!test_bit(AFS_VNODE_CB_BROKEN
, &vnode
->flags
) &&
295 vnode
->cb_promised
) {
296 spin_unlock(&vnode
->lock
);
297 _leave(" [unchanged]");
301 ASSERTCMP(vnode
->update_cnt
, >=, 0);
303 if (vnode
->update_cnt
> 0) {
304 /* someone else started a fetch */
305 _debug("wait on fetch %d", vnode
->update_cnt
);
307 set_current_state(TASK_UNINTERRUPTIBLE
);
308 ASSERT(myself
.func
!= NULL
);
309 add_wait_queue(&vnode
->update_waitq
, &myself
);
311 /* wait for the status to be updated */
313 if (!test_bit(AFS_VNODE_CB_BROKEN
, &vnode
->flags
))
315 if (test_bit(AFS_VNODE_DELETED
, &vnode
->flags
))
318 /* check to see if it got updated and invalidated all
319 * before we saw it */
320 if (vnode
->update_cnt
== 0) {
321 remove_wait_queue(&vnode
->update_waitq
,
323 set_current_state(TASK_RUNNING
);
327 spin_unlock(&vnode
->lock
);
330 set_current_state(TASK_UNINTERRUPTIBLE
);
332 spin_lock(&vnode
->lock
);
335 remove_wait_queue(&vnode
->update_waitq
, &myself
);
336 spin_unlock(&vnode
->lock
);
337 set_current_state(TASK_RUNNING
);
339 return test_bit(AFS_VNODE_DELETED
, &vnode
->flags
) ?
344 /* okay... we're going to have to initiate the op */
347 spin_unlock(&vnode
->lock
);
349 /* merge AFS status fetches and clear outstanding callback on this
352 /* pick a server to query */
353 server
= afs_volume_pick_fileserver(vnode
);
357 _debug("USING SERVER: %p{%08x}",
358 server
, ntohl(server
->addr
.s_addr
));
360 ret
= afs_fs_fetch_file_status(server
, key
, vnode
, NULL
,
363 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
365 /* adjust the flags */
369 afs_cache_permit(vnode
, key
, acl_order
);
370 afs_vnode_finalise_status_update(vnode
, server
);
371 afs_put_server(server
);
373 _debug("failed [%d]", ret
);
374 afs_vnode_status_update_failed(vnode
, ret
);
377 ASSERTCMP(vnode
->update_cnt
, >=, 0);
379 _leave(" = %d [cnt %d]", ret
, vnode
->update_cnt
);
383 spin_lock(&vnode
->lock
);
385 ASSERTCMP(vnode
->update_cnt
, >=, 0);
386 spin_unlock(&vnode
->lock
);
387 _leave(" = %ld [cnt %d]", PTR_ERR(server
), vnode
->update_cnt
);
388 return PTR_ERR(server
);
392 * fetch file data from the volume
393 * - TODO implement caching
395 int afs_vnode_fetch_data(struct afs_vnode
*vnode
, struct key
*key
,
396 off_t offset
, size_t length
, struct page
*page
)
398 struct afs_server
*server
;
401 _enter("%s{%x:%u.%u},%x,,,",
402 vnode
->volume
->vlocation
->vldb
.name
,
408 /* this op will fetch the status */
409 spin_lock(&vnode
->lock
);
411 spin_unlock(&vnode
->lock
);
413 /* merge in AFS status fetches and clear outstanding callback on this
416 /* pick a server to query */
417 server
= afs_volume_pick_fileserver(vnode
);
421 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
423 ret
= afs_fs_fetch_data(server
, key
, vnode
, offset
, length
,
424 page
, &afs_sync_call
);
426 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
428 /* adjust the flags */
430 afs_vnode_finalise_status_update(vnode
, server
);
431 afs_put_server(server
);
433 afs_vnode_status_update_failed(vnode
, ret
);
436 _leave(" = %d", ret
);
440 spin_lock(&vnode
->lock
);
442 ASSERTCMP(vnode
->update_cnt
, >=, 0);
443 spin_unlock(&vnode
->lock
);
444 return PTR_ERR(server
);
448 * make a file or a directory
450 int afs_vnode_create(struct afs_vnode
*vnode
, struct key
*key
,
451 const char *name
, umode_t mode
, struct afs_fid
*newfid
,
452 struct afs_file_status
*newstatus
,
453 struct afs_callback
*newcb
, struct afs_server
**_server
)
455 struct afs_server
*server
;
458 _enter("%s{%x:%u.%u},%x,%s,,",
459 vnode
->volume
->vlocation
->vldb
.name
,
466 /* this op will fetch the status on the directory we're creating in */
467 spin_lock(&vnode
->lock
);
469 spin_unlock(&vnode
->lock
);
472 /* pick a server to query */
473 server
= afs_volume_pick_fileserver(vnode
);
477 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
479 ret
= afs_fs_create(server
, key
, vnode
, name
, mode
, newfid
,
480 newstatus
, newcb
, &afs_sync_call
);
482 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
484 /* adjust the flags */
486 afs_vnode_finalise_status_update(vnode
, server
);
489 afs_vnode_status_update_failed(vnode
, ret
);
493 _leave(" = %d [cnt %d]", ret
, vnode
->update_cnt
);
497 spin_lock(&vnode
->lock
);
499 ASSERTCMP(vnode
->update_cnt
, >=, 0);
500 spin_unlock(&vnode
->lock
);
501 _leave(" = %ld [cnt %d]", PTR_ERR(server
), vnode
->update_cnt
);
502 return PTR_ERR(server
);
506 * remove a file or directory
508 int afs_vnode_remove(struct afs_vnode
*vnode
, struct key
*key
, const char *name
,
511 struct afs_server
*server
;
514 _enter("%s{%x:%u.%u},%x,%s",
515 vnode
->volume
->vlocation
->vldb
.name
,
522 /* this op will fetch the status on the directory we're removing from */
523 spin_lock(&vnode
->lock
);
525 spin_unlock(&vnode
->lock
);
528 /* pick a server to query */
529 server
= afs_volume_pick_fileserver(vnode
);
533 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
535 ret
= afs_fs_remove(server
, key
, vnode
, name
, isdir
,
538 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
540 /* adjust the flags */
542 afs_vnode_finalise_status_update(vnode
, server
);
543 afs_put_server(server
);
545 afs_vnode_status_update_failed(vnode
, ret
);
548 _leave(" = %d [cnt %d]", ret
, vnode
->update_cnt
);
552 spin_lock(&vnode
->lock
);
554 ASSERTCMP(vnode
->update_cnt
, >=, 0);
555 spin_unlock(&vnode
->lock
);
556 _leave(" = %ld [cnt %d]", PTR_ERR(server
), vnode
->update_cnt
);
557 return PTR_ERR(server
);
563 int afs_vnode_link(struct afs_vnode
*dvnode
, struct afs_vnode
*vnode
,
564 struct key
*key
, const char *name
)
566 struct afs_server
*server
;
569 _enter("%s{%x:%u.%u},%s{%x:%u.%u},%x,%s",
570 dvnode
->volume
->vlocation
->vldb
.name
,
574 vnode
->volume
->vlocation
->vldb
.name
,
581 /* this op will fetch the status on the directory we're removing from */
582 spin_lock(&vnode
->lock
);
584 spin_unlock(&vnode
->lock
);
585 spin_lock(&dvnode
->lock
);
586 dvnode
->update_cnt
++;
587 spin_unlock(&dvnode
->lock
);
590 /* pick a server to query */
591 server
= afs_volume_pick_fileserver(dvnode
);
595 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
597 ret
= afs_fs_link(server
, key
, dvnode
, vnode
, name
,
600 } while (!afs_volume_release_fileserver(dvnode
, server
, ret
));
602 /* adjust the flags */
604 afs_vnode_finalise_status_update(vnode
, server
);
605 afs_vnode_finalise_status_update(dvnode
, server
);
606 afs_put_server(server
);
608 afs_vnode_status_update_failed(vnode
, ret
);
609 afs_vnode_status_update_failed(dvnode
, ret
);
612 _leave(" = %d [cnt %d]", ret
, vnode
->update_cnt
);
616 spin_lock(&vnode
->lock
);
618 ASSERTCMP(vnode
->update_cnt
, >=, 0);
619 spin_unlock(&vnode
->lock
);
620 spin_lock(&dvnode
->lock
);
621 dvnode
->update_cnt
--;
622 ASSERTCMP(dvnode
->update_cnt
, >=, 0);
623 spin_unlock(&dvnode
->lock
);
624 _leave(" = %ld [cnt %d]", PTR_ERR(server
), vnode
->update_cnt
);
625 return PTR_ERR(server
);
629 * create a symbolic link
631 int afs_vnode_symlink(struct afs_vnode
*vnode
, struct key
*key
,
632 const char *name
, const char *content
,
633 struct afs_fid
*newfid
,
634 struct afs_file_status
*newstatus
,
635 struct afs_server
**_server
)
637 struct afs_server
*server
;
640 _enter("%s{%x:%u.%u},%x,%s,%s,,,",
641 vnode
->volume
->vlocation
->vldb
.name
,
648 /* this op will fetch the status on the directory we're creating in */
649 spin_lock(&vnode
->lock
);
651 spin_unlock(&vnode
->lock
);
654 /* pick a server to query */
655 server
= afs_volume_pick_fileserver(vnode
);
659 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
661 ret
= afs_fs_symlink(server
, key
, vnode
, name
, content
,
662 newfid
, newstatus
, &afs_sync_call
);
664 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
666 /* adjust the flags */
668 afs_vnode_finalise_status_update(vnode
, server
);
671 afs_vnode_status_update_failed(vnode
, ret
);
675 _leave(" = %d [cnt %d]", ret
, vnode
->update_cnt
);
679 spin_lock(&vnode
->lock
);
681 ASSERTCMP(vnode
->update_cnt
, >=, 0);
682 spin_unlock(&vnode
->lock
);
683 _leave(" = %ld [cnt %d]", PTR_ERR(server
), vnode
->update_cnt
);
684 return PTR_ERR(server
);
690 int afs_vnode_rename(struct afs_vnode
*orig_dvnode
,
691 struct afs_vnode
*new_dvnode
,
693 const char *orig_name
,
694 const char *new_name
)
696 struct afs_server
*server
;
699 _enter("%s{%x:%u.%u},%s{%u,%u,%u},%x,%s,%s",
700 orig_dvnode
->volume
->vlocation
->vldb
.name
,
701 orig_dvnode
->fid
.vid
,
702 orig_dvnode
->fid
.vnode
,
703 orig_dvnode
->fid
.unique
,
704 new_dvnode
->volume
->vlocation
->vldb
.name
,
706 new_dvnode
->fid
.vnode
,
707 new_dvnode
->fid
.unique
,
712 /* this op will fetch the status on both the directories we're dealing
714 spin_lock(&orig_dvnode
->lock
);
715 orig_dvnode
->update_cnt
++;
716 spin_unlock(&orig_dvnode
->lock
);
717 if (new_dvnode
!= orig_dvnode
) {
718 spin_lock(&new_dvnode
->lock
);
719 new_dvnode
->update_cnt
++;
720 spin_unlock(&new_dvnode
->lock
);
724 /* pick a server to query */
725 server
= afs_volume_pick_fileserver(orig_dvnode
);
729 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
731 ret
= afs_fs_rename(server
, key
, orig_dvnode
, orig_name
,
732 new_dvnode
, new_name
, &afs_sync_call
);
734 } while (!afs_volume_release_fileserver(orig_dvnode
, server
, ret
));
736 /* adjust the flags */
738 afs_vnode_finalise_status_update(orig_dvnode
, server
);
739 if (new_dvnode
!= orig_dvnode
)
740 afs_vnode_finalise_status_update(new_dvnode
, server
);
741 afs_put_server(server
);
743 afs_vnode_status_update_failed(orig_dvnode
, ret
);
744 if (new_dvnode
!= orig_dvnode
)
745 afs_vnode_status_update_failed(new_dvnode
, ret
);
748 _leave(" = %d [cnt %d]", ret
, orig_dvnode
->update_cnt
);
752 spin_lock(&orig_dvnode
->lock
);
753 orig_dvnode
->update_cnt
--;
754 ASSERTCMP(orig_dvnode
->update_cnt
, >=, 0);
755 spin_unlock(&orig_dvnode
->lock
);
756 if (new_dvnode
!= orig_dvnode
) {
757 spin_lock(&new_dvnode
->lock
);
758 new_dvnode
->update_cnt
--;
759 ASSERTCMP(new_dvnode
->update_cnt
, >=, 0);
760 spin_unlock(&new_dvnode
->lock
);
762 _leave(" = %ld [cnt %d]", PTR_ERR(server
), orig_dvnode
->update_cnt
);
763 return PTR_ERR(server
);
769 int afs_vnode_store_data(struct afs_writeback
*wb
, pgoff_t first
, pgoff_t last
,
770 unsigned offset
, unsigned to
)
772 struct afs_server
*server
;
773 struct afs_vnode
*vnode
= wb
->vnode
;
776 _enter("%s{%x:%u.%u},%x,%lx,%lx,%x,%x",
777 vnode
->volume
->vlocation
->vldb
.name
,
782 first
, last
, offset
, to
);
784 /* this op will fetch the status */
785 spin_lock(&vnode
->lock
);
787 spin_unlock(&vnode
->lock
);
790 /* pick a server to query */
791 server
= afs_volume_pick_fileserver(vnode
);
795 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
797 ret
= afs_fs_store_data(server
, wb
, first
, last
, offset
, to
,
800 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
802 /* adjust the flags */
804 afs_vnode_finalise_status_update(vnode
, server
);
805 afs_put_server(server
);
807 afs_vnode_status_update_failed(vnode
, ret
);
810 _leave(" = %d", ret
);
814 spin_lock(&vnode
->lock
);
816 ASSERTCMP(vnode
->update_cnt
, >=, 0);
817 spin_unlock(&vnode
->lock
);
818 return PTR_ERR(server
);
822 * set the attributes on a file
824 int afs_vnode_setattr(struct afs_vnode
*vnode
, struct key
*key
,
827 struct afs_server
*server
;
830 _enter("%s{%x:%u.%u},%x",
831 vnode
->volume
->vlocation
->vldb
.name
,
837 /* this op will fetch the status */
838 spin_lock(&vnode
->lock
);
840 spin_unlock(&vnode
->lock
);
843 /* pick a server to query */
844 server
= afs_volume_pick_fileserver(vnode
);
848 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
850 ret
= afs_fs_setattr(server
, key
, vnode
, attr
, &afs_sync_call
);
852 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
854 /* adjust the flags */
856 afs_vnode_finalise_status_update(vnode
, server
);
857 afs_put_server(server
);
859 afs_vnode_status_update_failed(vnode
, ret
);
862 _leave(" = %d", ret
);
866 spin_lock(&vnode
->lock
);
868 ASSERTCMP(vnode
->update_cnt
, >=, 0);
869 spin_unlock(&vnode
->lock
);
870 return PTR_ERR(server
);
874 * get the status of a volume
876 int afs_vnode_get_volume_status(struct afs_vnode
*vnode
, struct key
*key
,
877 struct afs_volume_status
*vs
)
879 struct afs_server
*server
;
882 _enter("%s{%x:%u.%u},%x,",
883 vnode
->volume
->vlocation
->vldb
.name
,
890 /* pick a server to query */
891 server
= afs_volume_pick_fileserver(vnode
);
895 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
897 ret
= afs_fs_get_volume_status(server
, key
, vnode
, vs
, &afs_sync_call
);
899 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
901 /* adjust the flags */
903 afs_put_server(server
);
905 _leave(" = %d", ret
);
909 return PTR_ERR(server
);
913 * get a lock on a file
915 int afs_vnode_set_lock(struct afs_vnode
*vnode
, struct key
*key
,
916 afs_lock_type_t type
)
918 struct afs_server
*server
;
921 _enter("%s{%x:%u.%u},%x,%u",
922 vnode
->volume
->vlocation
->vldb
.name
,
926 key_serial(key
), type
);
929 /* pick a server to query */
930 server
= afs_volume_pick_fileserver(vnode
);
934 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
936 ret
= afs_fs_set_lock(server
, key
, vnode
, type
, &afs_sync_call
);
938 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
940 /* adjust the flags */
942 afs_put_server(server
);
944 _leave(" = %d", ret
);
948 return PTR_ERR(server
);
952 * extend a lock on a file
954 int afs_vnode_extend_lock(struct afs_vnode
*vnode
, struct key
*key
)
956 struct afs_server
*server
;
959 _enter("%s{%x:%u.%u},%x",
960 vnode
->volume
->vlocation
->vldb
.name
,
967 /* pick a server to query */
968 server
= afs_volume_pick_fileserver(vnode
);
972 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
974 ret
= afs_fs_extend_lock(server
, key
, vnode
, &afs_sync_call
);
976 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
978 /* adjust the flags */
980 afs_put_server(server
);
982 _leave(" = %d", ret
);
986 return PTR_ERR(server
);
990 * release a lock on a file
992 int afs_vnode_release_lock(struct afs_vnode
*vnode
, struct key
*key
)
994 struct afs_server
*server
;
997 _enter("%s{%x:%u.%u},%x",
998 vnode
->volume
->vlocation
->vldb
.name
,
1005 /* pick a server to query */
1006 server
= afs_volume_pick_fileserver(vnode
);
1010 _debug("USING SERVER: %08x\n", ntohl(server
->addr
.s_addr
));
1012 ret
= afs_fs_release_lock(server
, key
, vnode
, &afs_sync_call
);
1014 } while (!afs_volume_release_fileserver(vnode
, server
, ret
));
1016 /* adjust the flags */
1018 afs_put_server(server
);
1020 _leave(" = %d", ret
);
1024 return PTR_ERR(server
);
This page took 0.053266 seconds and 5 git commands to generate.