/* * Copyright (c) 2002, 2007 Red Hat, Inc. All rights reserved. * * This software may be freely redistributed under the terms of the * GNU General Public License. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Authors: David Woodhouse <dwmw2@infradead.org> * David Howells <dhowells@redhat.com> *
*/
/* * Handle invalidation of an mmap'd file. We invalidate all the PTEs referring * to the pages in this file's pagecache, forcing the kernel to go through * ->fault() or ->page_mkwrite() - at which point we can handle invalidation * more fully.
*/ void afs_invalidate_mmap_work(struct work_struct *work)
{ struct afs_vnode *vnode = container_of(work, struct afs_vnode, cb_work);
/* * Look up a volume by volume ID under RCU conditions.
*/ staticstruct afs_volume *afs_lookup_volume_rcu(struct afs_cell *cell,
afs_volid_t vid)
{ struct afs_volume *volume = NULL; struct rb_node *p; int seq = 1;
for (;;) { /* Unfortunately, rbtree walking doesn't give reliable results * under just the RCU read lock, so we have to check for * changes.
*/
seq++; /* 2 on the 1st/lockless path, otherwise odd */
read_seqbegin_or_lock(&cell->volume_lock, &seq);
p = rcu_dereference_raw(cell->volumes.rb_node); while (p) {
volume = rb_entry(p, struct afs_volume, cell_node);
if (volume->vid < vid)
p = rcu_dereference_raw(p->rb_left); elseif (volume->vid > vid)
p = rcu_dereference_raw(p->rb_right); else break;
volume = NULL;
}
if (volume && afs_try_get_volume(volume, afs_volume_trace_get_callback)) break; if (!need_seqretry(&cell->volume_lock, seq)) break;
seq |= 1; /* Want a lock next time */
}
/* * Allow the fileserver to break callbacks at the volume-level. This is * typically done when, for example, a R/W volume is snapshotted to a R/O * volume (the only way to change an R/O volume). It may also, however, happen * when a volserver takes control of a volume (offlining it, moving it, etc.). * * Every file in that volume will need to be reevaluated.
*/ staticvoid afs_break_volume_callback(struct afs_server *server, struct afs_volume *volume)
__releases(RCU)
{ struct afs_server_list *slist = rcu_dereference(volume->servers); unsignedint i, cb_v_break;
write_lock(&volume->cb_v_break_lock);
for (i = 0; i < slist->nr_servers; i++) if (slist->servers[i].server == server)
slist->servers[i].cb_expires_at = AFS_NO_CB_PROMISE;
volume->cb_expires_at = AFS_NO_CB_PROMISE;
if (!list_empty(&volume->open_mmaps))
afs_volume_init_callback(volume);
}
/* * allow the fileserver to explicitly break one callback * - happens when * - the backing file is changed * - a lock is released
*/ staticvoid afs_break_one_callback(struct afs_server *server, struct afs_volume *volume, struct afs_fid *fid)
{ struct super_block *sb; struct afs_vnode *vnode; struct inode *inode;
/* See if we can find a matching inode - even an I_NEW inode needs to * be marked as it can have its callback broken before we finish * setting up the local inode.
*/
sb = rcu_dereference(volume->sb); if (!sb) return;
rcu_read_lock();
volume = afs_lookup_volume_rcu(server->cell, vid); if (cbb->fid.vnode == 0 && cbb->fid.unique == 0) {
afs_break_volume_callback(server, volume);
*_count -= 1; if (*_count)
memmove(cbb, cbb + 1, sizeof(*cbb) * *_count);
} else { /* TODO: Find all matching volumes if we couldn't match the server and * break them anyway.
*/
for (i = *_count; i > 0; cbb++, i--) { if (cbb->fid.vid == vid) {
_debug("- Fid { vl=%08llx n=%llu u=%u }",
cbb->fid.vid,
cbb->fid.vnode,
cbb->fid.unique);
--*_count; if (volume)
afs_break_one_callback(server, volume, &cbb->fid);
} else {
*residue++ = *cbb;
}
}
rcu_read_unlock();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.