ceph: return EBADF if waiting for caps on closed file

Verify the file is actually open for the given caps when we are
waiting for caps.  This ensures we will wake up and return EBADF
if another thread closes the file out from under us.

Note that EBADF is also the correct return code from write(2)
when called on a file handle opened for reading (although the
vfs should catch that).

Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
Sage Weil 2010-03-01 09:57:54 -08:00
parent 6f863e712d
commit 195d3ce2cc
2 changed files with 9 additions and 3 deletions

View file

@ -262,6 +262,9 @@ int ceph_release(struct inode *inode, struct file *file)
kfree(cf->dir_info);
dput(cf->dentry);
kmem_cache_free(ceph_file_cachep, cf);
/* wake up anyone waiting for caps on this inode */
wake_up(&ci->i_cap_wq);
return 0;
}