Skip to content

Commit

Permalink
AFS: implement file locking
Browse files Browse the repository at this point in the history
Implement file locking for AFS.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
dhowells authored and Linus Torvalds committed Jul 16, 2007
1 parent b0fed31 commit e8d6c55
Show file tree
Hide file tree
Showing 14 changed files with 885 additions and 15 deletions.
1 change: 1 addition & 0 deletions fs/afs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ kafs-objs := \
cmservice.o \
dir.o \
file.o \
flock.o \
fsclient.o \
inode.o \
main.o \
Expand Down
8 changes: 8 additions & 0 deletions fs/afs/afs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ typedef enum {
AFS_FTYPE_SYMLINK = 3,
} afs_file_type_t;

typedef enum {
AFS_LOCK_READ = 0, /* read lock request */
AFS_LOCK_WRITE = 1, /* write lock request */
} afs_lock_type_t;

#define AFS_LOCKWAIT (5 * 60) /* time until a lock times out (seconds) */

/*
* AFS file identifier
*/
Expand Down Expand Up @@ -120,6 +127,7 @@ struct afs_file_status {
struct afs_fid parent; /* parent dir ID for non-dirs only */
time_t mtime_client; /* last time client changed data */
time_t mtime_server; /* last time server changed data */
s32 lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
};

/*
Expand Down
3 changes: 3 additions & 0 deletions fs/afs/afs_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ enum AFS_FS_Operations {
FSGETVOLUMEINFO = 148, /* AFS Get information about a volume */
FSGETVOLUMESTATUS = 149, /* AFS Get volume status information */
FSGETROOTVOLUME = 151, /* AFS Get root volume name */
FSSETLOCK = 156, /* AFS Request a file lock */
FSEXTENDLOCK = 157, /* AFS Extend a file lock */
FSRELEASELOCK = 158, /* AFS Release a file lock */
FSLOOKUP = 161, /* AFS lookup file in directory */
FSFETCHDATA64 = 65537, /* AFS Fetch file data */
FSSTOREDATA64 = 65538, /* AFS Store file data */
Expand Down
3 changes: 3 additions & 0 deletions fs/afs/callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ static void afs_break_callback(struct afs_server *server,
spin_unlock(&server->cb_lock);

queue_work(afs_callback_update_worker, &vnode->cb_broken_work);
if (list_empty(&vnode->granted_locks) &&
!list_empty(&vnode->pending_locks))
afs_lock_may_be_available(vnode);
spin_unlock(&vnode->lock);
}
}
Expand Down
1 change: 1 addition & 0 deletions fs/afs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const struct file_operations afs_dir_file_operations = {
.open = afs_dir_open,
.release = afs_release,
.readdir = afs_readdir,
.lock = afs_lock,
};

const struct inode_operations afs_dir_inode_operations = {
Expand Down
2 changes: 2 additions & 0 deletions fs/afs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const struct file_operations afs_file_operations = {
.mmap = generic_file_readonly_mmap,
.splice_read = generic_file_splice_read,
.fsync = afs_fsync,
.lock = afs_lock,
.flock = afs_flock,
};

const struct inode_operations afs_file_inode_operations = {
Expand Down
Loading

0 comments on commit e8d6c55

Please sign in to comment.