summaryrefslogtreecommitdiffstats
path: root/fs/afs/vnode.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2017-11-02 15:27:50 +0000
committerDavid Howells <dhowells@redhat.com>2017-11-13 15:38:19 +0000
commitd2ddc776a4581d900fc3bdc7803b403daae64d88 (patch)
tree6c5f6bac9e9e9a326ed0a9248914b53c421558e5 /fs/afs/vnode.c
parent9cc6fc50f7bc69ac28bee45eed13cbc65a86210f (diff)
downloadop-kernel-dev-d2ddc776a4581d900fc3bdc7803b403daae64d88.zip
op-kernel-dev-d2ddc776a4581d900fc3bdc7803b403daae64d88.tar.gz
afs: Overhaul volume and server record caching and fileserver rotation
The current code assumes that volumes and servers are per-cell and are never shared, but this is not enforced, and, indeed, public cells do exist that are aliases of each other. Further, an organisation can, say, set up a public cell and a private cell with overlapping, but not identical, sets of servers. The difference is purely in the database attached to the VL servers. The current code will malfunction if it sees a server in two cells as it assumes global address -> server record mappings and that each server is in just one cell. Further, each server may have multiple addresses - and may have addresses of different families (IPv4 and IPv6, say). To this end, the following structural changes are made: (1) Server record management is overhauled: (a) Server records are made independent of cell. The namespace keeps track of them, volume records have lists of them and each vnode has a server on which its callback interest currently resides. (b) The cell record no longer keeps a list of servers known to be in that cell. (c) The server records are now kept in a flat list because there's no single address to sort on. (d) Server records are now keyed by their UUID within the namespace. (e) The addresses for a server are obtained with the VL.GetAddrsU rather than with VL.GetEntryByName, using the server's UUID as a parameter. (f) Cached server records are garbage collected after a period of non-use and are counted out of existence before purging is allowed to complete. This protects the work functions against rmmod. (g) The servers list is now in /proc/fs/afs/servers. (2) Volume record management is overhauled: (a) An RCU-replaceable server list is introduced. This tracks both servers and their coresponding callback interests. (b) The superblock is now keyed on cell record and numeric volume ID. (c) The volume record is now tied to the superblock which mounts it, and is activated when mounted and deactivated when unmounted. This makes it easier to handle the cache cookie without causing a double-use in fscache. (d) The volume record is loaded from the VLDB using VL.GetEntryByNameU to get the server UUID list. (e) The volume name is updated if it is seen to have changed when the volume is updated (the update is keyed on the volume ID). (3) The vlocation record is got rid of and VLDB records are no longer cached. Sufficient information is stored in the volume record, though an update to a volume record is now no longer shared between related volumes (volumes come in bundles of three: R/W, R/O and backup). and the following procedural changes are made: (1) The fileserver cursor introduced previously is now fleshed out and used to iterate over fileservers and their addresses. (2) Volume status is checked during iteration, and the server list is replaced if a change is detected. (3) Server status is checked during iteration, and the address list is replaced if a change is detected. (4) The abort code is saved into the address list cursor and -ECONNABORTED returned in afs_make_call() if a remote abort happened rather than translating the abort into an error message. This allows actions to be taken depending on the abort code more easily. (a) If a VMOVED abort is seen then this is handled by rechecking the volume and restarting the iteration. (b) If a VBUSY, VRESTARTING or VSALVAGING abort is seen then this is handled by sleeping for a short period and retrying and/or trying other servers that might serve that volume. A message is also displayed once until the condition has cleared. (c) If a VOFFLINE abort is seen, then this is handled as VBUSY for the moment. (d) If a VNOVOL abort is seen, the volume is rechecked in the VLDB to see if it has been deleted; if not, the fileserver is probably indicating that the volume couldn't be attached and needs salvaging. (e) If statfs() sees one of these aborts, it does not sleep, but rather returns an error, so as not to block the umount program. (5) The fileserver iteration functions in vnode.c are now merged into their callers and more heavily macroised around the cursor. vnode.c is removed. (6) Operations on a particular vnode are serialised on that vnode because the server will lock that vnode whilst it operates on it, so a second op sent will just have to wait. (7) Fileservers are probed with FS.GetCapabilities before being used. This is where service upgrade will be done. (8) A callback interest on a fileserver is set up before an FS operation is performed and passed through to afs_make_call() so that it can be set on the vnode if the operation returns a callback. The callback interest is passed through to afs_iget() also so that it can be set there too. In general, record updating is done on an as-needed basis when we try to access servers, volumes or vnodes rather than offloading it to work items and special threads. Notes: (1) Pre AFS-3.4 servers are no longer supported, though this can be added back if necessary (AFS-3.4 was released in 1998). (2) VBUSY is retried forever for the moment at intervals of 1s. (3) /proc/fs/afs/<cell>/servers no longer exists. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs/vnode.c')
-rw-r--r--fs/afs/vnode.c750
1 files changed, 0 insertions, 750 deletions
diff --git a/fs/afs/vnode.c b/fs/afs/vnode.c
deleted file mode 100644
index 9c7333e..0000000
--- a/fs/afs/vnode.c
+++ /dev/null
@@ -1,750 +0,0 @@
-/* AFS vnode management
- *
- * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
- * Written by David Howells (dhowells@redhat.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/fs.h>
-#include <linux/sched.h>
-#include "internal.h"
-
-/*
- * Handle remote file deletion.
- */
-static void afs_vnode_deleted_remotely(struct afs_vnode *vnode)
-{
- struct afs_cb_interest *cbi = vnode->cb_interest;
-
- _enter("{%p}", cbi);
-
- set_bit(AFS_VNODE_DELETED, &vnode->flags);
-
- if (cbi) {
- vnode->cb_interest = NULL;
- afs_put_cb_interest(afs_v2net(vnode), cbi);
- }
-
- _leave("");
-}
-
-/*
- * finish off updating the recorded status of a file after a successful
- * operation completion
- * - starts callback expiry timer
- * - adds to server's callback list
- */
-void afs_vnode_finalise_status_update(struct afs_vnode *vnode,
- struct afs_server *server)
-{
- spin_lock(&vnode->lock);
- vnode->update_cnt--;
- ASSERTCMP(vnode->update_cnt, >=, 0);
- spin_unlock(&vnode->lock);
-
- wake_up_all(&vnode->update_waitq);
- _leave("");
-}
-
-/*
- * finish off updating the recorded status of a file after an operation failed
- */
-static void afs_vnode_status_update_failed(struct afs_fs_cursor *fc,
- struct afs_vnode *vnode)
-{
- _enter("{%x:%u},%d", vnode->fid.vid, vnode->fid.vnode, fc->ac.error);
-
- spin_lock(&vnode->lock);
-
- if (fc->ac.error == -ENOENT) {
- /* the file was deleted on the server */
- _debug("got NOENT from server - marking file deleted");
- afs_vnode_deleted_remotely(vnode);
- }
-
- vnode->update_cnt--;
- ASSERTCMP(vnode->update_cnt, >=, 0);
- spin_unlock(&vnode->lock);
-
- wake_up_all(&vnode->update_waitq);
- _leave("");
-}
-
-/*
- * fetch file status from the volume
- * - don't issue a fetch if:
- * - the changed bit is not set and there's a valid callback
- * - there are any outstanding ops that will fetch the status
- * - TODO implement local caching
- */
-int afs_vnode_fetch_status(struct afs_vnode *vnode, struct key *key, bool force)
-{
- struct afs_fs_cursor fc;
- unsigned int cb_break = 0;
-
- DECLARE_WAITQUEUE(myself, current);
-
- _enter("%s,{%x:%u.%u,S=%lx},%u",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique,
- vnode->flags,
- force);
-
- if (!force && test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags)) {
- _leave(" [unchanged]");
- return 0;
- }
-
- if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
- _leave(" [deleted]");
- return -ENOENT;
- }
-
- cb_break = vnode->cb_break + vnode->cb_s_break;
-
- spin_lock(&vnode->lock);
-
- if (!force && test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags)) {
- spin_unlock(&vnode->lock);
- _leave(" [unchanged]");
- return 0;
- }
-
- ASSERTCMP(vnode->update_cnt, >=, 0);
-
- if (vnode->update_cnt > 0) {
- /* someone else started a fetch */
- _debug("wait on fetch %d", vnode->update_cnt);
-
- set_current_state(TASK_UNINTERRUPTIBLE);
- ASSERT(myself.func != NULL);
- add_wait_queue(&vnode->update_waitq, &myself);
-
- /* wait for the status to be updated */
- for (;;) {
- if (test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags))
- break;
- if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
- break;
-
- /* check to see if it got updated and invalidated all
- * before we saw it */
- if (vnode->update_cnt == 0) {
- remove_wait_queue(&vnode->update_waitq,
- &myself);
- set_current_state(TASK_RUNNING);
- goto get_anyway;
- }
-
- spin_unlock(&vnode->lock);
-
- schedule();
- set_current_state(TASK_UNINTERRUPTIBLE);
-
- spin_lock(&vnode->lock);
- }
-
- remove_wait_queue(&vnode->update_waitq, &myself);
- spin_unlock(&vnode->lock);
- set_current_state(TASK_RUNNING);
-
- return test_bit(AFS_VNODE_DELETED, &vnode->flags) ?
- -ENOENT : 0;
- }
-
-get_anyway:
- /* okay... we're going to have to initiate the op */
- vnode->update_cnt++;
-
- spin_unlock(&vnode->lock);
-
- /* merge AFS status fetches and clear outstanding callback on this
- * vnode */
- afs_init_fs_cursor(&fc, vnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, vnode))
- goto no_server;
-
- fc.ac.error = afs_fs_fetch_file_status(&fc, key, vnode, NULL, false);
-
- } while (afs_iterate_fs_cursor(&fc, vnode));
-
- /* adjust the flags */
- if (fc.ac.error == 0) {
- _debug("adjust");
- afs_cache_permit(vnode, key, cb_break);
- afs_vnode_finalise_status_update(vnode, fc.server);
- } else {
- _debug("failed [%d]", fc.ac.error);
- afs_vnode_status_update_failed(&fc, vnode);
- }
-
-out:
- afs_end_fs_cursor(&fc, afs_v2net(vnode));
- ASSERTCMP(vnode->update_cnt, >=, 0);
- _leave(" = %d [cnt %d]", fc.ac.error, vnode->update_cnt);
- return fc.ac.error;
-
-no_server:
- spin_lock(&vnode->lock);
- vnode->update_cnt--;
- spin_unlock(&vnode->lock);
- goto out;
-}
-
-/*
- * fetch file data from the volume
- * - TODO implement caching
- */
-int afs_vnode_fetch_data(struct afs_vnode *vnode, struct key *key,
- struct afs_read *desc)
-{
- struct afs_fs_cursor fc;
-
- _enter("%s{%x:%u.%u},%x,,,",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(key));
-
- /* this op will fetch the status */
- spin_lock(&vnode->lock);
- vnode->update_cnt++;
- spin_unlock(&vnode->lock);
-
- /* merge in AFS status fetches and clear outstanding callback on this
- * vnode */
- afs_init_fs_cursor(&fc, vnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, vnode))
- goto no_server;
-
- fc.ac.error = afs_fs_fetch_data(&fc, key, vnode, desc, false);
-
- } while (afs_iterate_fs_cursor(&fc, vnode));
-
- /* adjust the flags */
- if (fc.ac.error == 0)
- afs_vnode_finalise_status_update(vnode, fc.server);
- else
- afs_vnode_status_update_failed(&fc, vnode);
-
-out:
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-
-no_server:
- spin_lock(&vnode->lock);
- vnode->update_cnt--;
- ASSERTCMP(vnode->update_cnt, >=, 0);
- spin_unlock(&vnode->lock);
- goto out;
-}
-
-/*
- * make a file or a directory
- */
-int afs_vnode_create(struct afs_vnode *vnode, struct key *key,
- const char *name, umode_t mode, struct afs_fid *newfid,
- struct afs_file_status *newstatus,
- struct afs_callback *newcb, struct afs_server **_server)
-{
- struct afs_fs_cursor fc;
-
- _enter("%s{%x:%u.%u},%x,%s,,",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(key),
- name);
-
- /* this op will fetch the status on the directory we're creating in */
- spin_lock(&vnode->lock);
- vnode->update_cnt++;
- spin_unlock(&vnode->lock);
-
- afs_init_fs_cursor(&fc, vnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, vnode))
- goto no_server;
-
- fc.ac.error = afs_fs_create(&fc, key, vnode, name, mode, newfid,
- newstatus, newcb, false);
-
- } while (afs_iterate_fs_cursor(&fc, vnode));
-
- /* adjust the flags */
- if (fc.ac.error == 0) {
- afs_vnode_finalise_status_update(vnode, fc.server);
- *_server = fc.server;
- fc.server = NULL;
- } else {
- afs_vnode_status_update_failed(&fc, vnode);
- *_server = NULL;
- }
-
-out:
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-
-no_server:
- spin_lock(&vnode->lock);
- vnode->update_cnt--;
- ASSERTCMP(vnode->update_cnt, >=, 0);
- spin_unlock(&vnode->lock);
- goto out;
-}
-
-/*
- * remove a file or directory
- */
-int afs_vnode_remove(struct afs_vnode *vnode, struct key *key, const char *name,
- bool isdir)
-{
- struct afs_fs_cursor fc;
-
- _enter("%s{%x:%u.%u},%x,%s",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(key),
- name);
-
- /* this op will fetch the status on the directory we're removing from */
- spin_lock(&vnode->lock);
- vnode->update_cnt++;
- spin_unlock(&vnode->lock);
-
- afs_init_fs_cursor(&fc, vnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, vnode))
- goto no_server;
-
- fc.ac.error = afs_fs_remove(&fc, key, vnode, name, isdir, false);
-
- } while (afs_iterate_fs_cursor(&fc, vnode));
-
- /* adjust the flags */
- if (fc.ac.error == 0)
- afs_vnode_finalise_status_update(vnode, fc.server);
- else
- afs_vnode_status_update_failed(&fc, vnode);
-
-out:
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-
-no_server:
- spin_lock(&vnode->lock);
- vnode->update_cnt--;
- ASSERTCMP(vnode->update_cnt, >=, 0);
- spin_unlock(&vnode->lock);
- goto out;
-}
-
-/*
- * create a hard link
- */
-int afs_vnode_link(struct afs_vnode *dvnode, struct afs_vnode *vnode,
- struct key *key, const char *name)
-{
- struct afs_fs_cursor fc;
-
- _enter("%s{%x:%u.%u},%s{%x:%u.%u},%x,%s",
- dvnode->volume->vlocation->vldb.name,
- dvnode->fid.vid,
- dvnode->fid.vnode,
- dvnode->fid.unique,
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(key),
- name);
-
- /* this op will fetch the status on the directory we're removing from */
- spin_lock(&vnode->lock);
- vnode->update_cnt++;
- spin_unlock(&vnode->lock);
- spin_lock(&dvnode->lock);
- dvnode->update_cnt++;
- spin_unlock(&dvnode->lock);
-
- afs_init_fs_cursor(&fc, vnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, dvnode))
- goto no_server;
-
- fc.ac.error = afs_fs_link(&fc, key, dvnode, vnode, name, false);
-
- } while (afs_iterate_fs_cursor(&fc, dvnode));
-
- /* adjust the flags */
- if (fc.ac.error == 0) {
- afs_vnode_finalise_status_update(vnode, fc.server);
- afs_vnode_finalise_status_update(dvnode, fc.server);
- } else {
- afs_vnode_status_update_failed(&fc, vnode);
- afs_vnode_status_update_failed(&fc, dvnode);
- }
-
-out:
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-
-no_server:
- spin_lock(&vnode->lock);
- vnode->update_cnt--;
- ASSERTCMP(vnode->update_cnt, >=, 0);
- spin_unlock(&vnode->lock);
- spin_lock(&dvnode->lock);
- dvnode->update_cnt--;
- ASSERTCMP(dvnode->update_cnt, >=, 0);
- spin_unlock(&dvnode->lock);
- goto out;
-}
-
-/*
- * create a symbolic link
- */
-int afs_vnode_symlink(struct afs_vnode *vnode, struct key *key,
- const char *name, const char *content,
- struct afs_fid *newfid,
- struct afs_file_status *newstatus,
- struct afs_server **_server)
-{
- struct afs_fs_cursor fc;
-
- _enter("%s{%x:%u.%u},%x,%s,%s,,,",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(key),
- name, content);
-
- /* this op will fetch the status on the directory we're creating in */
- spin_lock(&vnode->lock);
- vnode->update_cnt++;
- spin_unlock(&vnode->lock);
-
- afs_init_fs_cursor(&fc, vnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, vnode))
- goto no_server;
-
- fc.ac.error = afs_fs_symlink(&fc, key, vnode, name, content,
- newfid, newstatus, false);
-
- } while (afs_iterate_fs_cursor(&fc, vnode));
-
- /* adjust the flags */
- if (fc.ac.error == 0) {
- afs_vnode_finalise_status_update(vnode, fc.server);
- *_server = fc.server;
- fc.server = NULL;
- } else {
- afs_vnode_status_update_failed(&fc, vnode);
- *_server = NULL;
- }
-
-out:
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-
-no_server:
- spin_lock(&vnode->lock);
- vnode->update_cnt--;
- ASSERTCMP(vnode->update_cnt, >=, 0);
- spin_unlock(&vnode->lock);
- *_server = NULL;
- goto out;
-}
-
-/*
- * rename a file
- */
-int afs_vnode_rename(struct afs_vnode *orig_dvnode,
- struct afs_vnode *new_dvnode,
- struct key *key,
- const char *orig_name,
- const char *new_name)
-{
- struct afs_fs_cursor fc;
-
- _enter("%s{%x:%u.%u},%s{%u,%u,%u},%x,%s,%s",
- orig_dvnode->volume->vlocation->vldb.name,
- orig_dvnode->fid.vid,
- orig_dvnode->fid.vnode,
- orig_dvnode->fid.unique,
- new_dvnode->volume->vlocation->vldb.name,
- new_dvnode->fid.vid,
- new_dvnode->fid.vnode,
- new_dvnode->fid.unique,
- key_serial(key),
- orig_name,
- new_name);
-
- /* this op will fetch the status on both the directories we're dealing
- * with */
- spin_lock(&orig_dvnode->lock);
- orig_dvnode->update_cnt++;
- spin_unlock(&orig_dvnode->lock);
- if (new_dvnode != orig_dvnode) {
- spin_lock(&new_dvnode->lock);
- new_dvnode->update_cnt++;
- spin_unlock(&new_dvnode->lock);
- }
-
- afs_init_fs_cursor(&fc, orig_dvnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, orig_dvnode))
- goto no_server;
-
- fc.ac.error = afs_fs_rename(&fc, key, orig_dvnode, orig_name,
- new_dvnode, new_name, false);
-
- } while (afs_iterate_fs_cursor(&fc, orig_dvnode));
-
- /* adjust the flags */
- if (fc.ac.error == 0) {
- afs_vnode_finalise_status_update(orig_dvnode, fc.server);
- if (new_dvnode != orig_dvnode)
- afs_vnode_finalise_status_update(new_dvnode, fc.server);
- } else {
- afs_vnode_status_update_failed(&fc, orig_dvnode);
- if (new_dvnode != orig_dvnode)
- afs_vnode_status_update_failed(&fc, new_dvnode);
- }
-
-out:
- return afs_end_fs_cursor(&fc, afs_v2net(orig_dvnode));
-
-no_server:
- spin_lock(&orig_dvnode->lock);
- orig_dvnode->update_cnt--;
- ASSERTCMP(orig_dvnode->update_cnt, >=, 0);
- spin_unlock(&orig_dvnode->lock);
- if (new_dvnode != orig_dvnode) {
- spin_lock(&new_dvnode->lock);
- new_dvnode->update_cnt--;
- ASSERTCMP(new_dvnode->update_cnt, >=, 0);
- spin_unlock(&new_dvnode->lock);
- }
- goto out;
-}
-
-/*
- * write to a file
- */
-int afs_vnode_store_data(struct afs_writeback *wb, pgoff_t first, pgoff_t last,
- unsigned offset, unsigned to)
-{
- struct afs_fs_cursor fc;
- struct afs_vnode *vnode = wb->vnode;
-
- _enter("%s{%x:%u.%u},%x,%lx,%lx,%x,%x",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(wb->key),
- first, last, offset, to);
-
- /* this op will fetch the status */
- spin_lock(&vnode->lock);
- vnode->update_cnt++;
- spin_unlock(&vnode->lock);
-
- afs_init_fs_cursor(&fc, vnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, vnode))
- goto no_server;
-
- fc.ac.error = afs_fs_store_data(&fc, wb, first, last, offset, to,
- false);
-
- } while (afs_iterate_fs_cursor(&fc, vnode));
-
- /* adjust the flags */
- if (fc.ac.error == 0) {
- afs_vnode_finalise_status_update(vnode, fc.server);
- } else {
- afs_vnode_status_update_failed(&fc, vnode);
- }
-
-out:
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-
-no_server:
- spin_lock(&vnode->lock);
- vnode->update_cnt--;
- ASSERTCMP(vnode->update_cnt, >=, 0);
- spin_unlock(&vnode->lock);
- goto out;
-}
-
-/*
- * set the attributes on a file
- */
-int afs_vnode_setattr(struct afs_vnode *vnode, struct key *key,
- struct iattr *attr)
-{
- struct afs_fs_cursor fc;
-
- _enter("%s{%x:%u.%u},%x",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(key));
-
- /* this op will fetch the status */
- spin_lock(&vnode->lock);
- vnode->update_cnt++;
- spin_unlock(&vnode->lock);
-
- afs_init_fs_cursor(&fc, vnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, vnode))
- goto no_server;
-
- fc.ac.error = afs_fs_setattr(&fc, key, vnode, attr, false);
-
- } while (afs_iterate_fs_cursor(&fc, vnode));
-
- /* adjust the flags */
- if (fc.ac.error == 0) {
- afs_vnode_finalise_status_update(vnode, fc.server);
- } else {
- afs_vnode_status_update_failed(&fc, vnode);
- }
-
-out:
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-
-no_server:
- spin_lock(&vnode->lock);
- vnode->update_cnt--;
- ASSERTCMP(vnode->update_cnt, >=, 0);
- spin_unlock(&vnode->lock);
- goto out;
-}
-
-/*
- * get the status of a volume
- */
-int afs_vnode_get_volume_status(struct afs_vnode *vnode, struct key *key,
- struct afs_volume_status *vs)
-{
- struct afs_fs_cursor fc;
-
- _enter("%s{%x:%u.%u},%x,",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(key));
-
- afs_init_fs_cursor(&fc, vnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, vnode))
- break;
-
- fc.ac.error = afs_fs_get_volume_status(&fc, key, vnode, vs, false);
-
- } while (afs_iterate_fs_cursor(&fc, vnode));
-
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-}
-
-/*
- * get a lock on a file
- */
-int afs_vnode_set_lock(struct afs_vnode *vnode, struct key *key,
- afs_lock_type_t type)
-{
- struct afs_fs_cursor fc;
-
- _enter("%s{%x:%u.%u},%x,%u",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(key), type);
-
- afs_init_fs_cursor(&fc, vnode);
- do {
- /* pick a server to query */
- if (!afs_volume_pick_fileserver(&fc, vnode))
- break;
-
- fc.ac.error = afs_fs_set_lock(&fc, key, vnode, type, false);
-
- } while (afs_iterate_fs_cursor(&fc, vnode));
-
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-}
-
-/*
- * extend a lock on a file
- */
-int afs_vnode_extend_lock(struct afs_vnode *vnode, struct key *key)
-{
- struct afs_fs_cursor fc;
- int ret;
-
- _enter("%s{%x:%u.%u},%x",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(key));
-
- ret = afs_set_fs_cursor(&fc, vnode);
- if (ret < 0)
- return ret;
-
- fc.ac.error = afs_fs_extend_lock(&fc, key, vnode, false);
-
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-}
-
-/*
- * release a lock on a file
- */
-int afs_vnode_release_lock(struct afs_vnode *vnode, struct key *key)
-{
- struct afs_fs_cursor fc;
- int ret;
-
- _enter("%s{%x:%u.%u},%x",
- vnode->volume->vlocation->vldb.name,
- vnode->fid.vid,
- vnode->fid.vnode,
- vnode->fid.unique,
- key_serial(key));
-
- ret = afs_set_fs_cursor(&fc, vnode);
- if (ret < 0)
- return ret;
-
- fc.ac.error = afs_fs_release_lock(&fc, key, vnode, false);
-
- return afs_end_fs_cursor(&fc, afs_v2net(vnode));
-}
OpenPOWER on IntegriCloud