Skip to content

Commit 2ee9dd9

Browse files
Luis Henriquesidryomov
authored andcommitted
ceph: add non-blocking parameter to ceph_try_get_caps()
ceph_try_get_caps currently calls try_get_cap_refs with the nonblock parameter always set to 'true'. This change adds a new parameter that allows to set it's value. This will be useful for a follow-up patch that will need to get two sets of capabilities for two different inodes without risking a deadlock. Signed-off-by: Luis Henriques <lhenriques@suse.com> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 98c4bfe commit 2ee9dd9

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

fs/ceph/addr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
322322
/* caller of readpages does not hold buffer and read caps
323323
* (fadvise, madvise and readahead cases) */
324324
int want = CEPH_CAP_FILE_CACHE;
325-
ret = ceph_try_get_caps(ci, CEPH_CAP_FILE_RD, want, &got);
325+
ret = ceph_try_get_caps(ci, CEPH_CAP_FILE_RD, want, true, &got);
326326
if (ret < 0) {
327327
dout("start_read %p, error getting cap\n", inode);
328328
} else if (!(got & want)) {

fs/ceph/caps.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,17 +2673,18 @@ static void check_max_size(struct inode *inode, loff_t endoff)
26732673
ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL);
26742674
}
26752675

2676-
int ceph_try_get_caps(struct ceph_inode_info *ci, int need, int want, int *got)
2676+
int ceph_try_get_caps(struct ceph_inode_info *ci, int need, int want,
2677+
bool nonblock, int *got)
26772678
{
26782679
int ret, err = 0;
26792680

26802681
BUG_ON(need & ~CEPH_CAP_FILE_RD);
2681-
BUG_ON(want & ~(CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO));
2682+
BUG_ON(want & ~(CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO|CEPH_CAP_FILE_SHARED));
26822683
ret = ceph_pool_perm_check(ci, need);
26832684
if (ret < 0)
26842685
return ret;
26852686

2686-
ret = try_get_cap_refs(ci, need, want, 0, true, got, &err);
2687+
ret = try_get_cap_refs(ci, need, want, 0, nonblock, got, &err);
26872688
if (ret) {
26882689
if (err == -EAGAIN) {
26892690
ret = 0;

fs/ceph/super.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ extern int ceph_encode_dentry_release(void **p, struct dentry *dn,
10081008
extern int ceph_get_caps(struct ceph_inode_info *ci, int need, int want,
10091009
loff_t endoff, int *got, struct page **pinned_page);
10101010
extern int ceph_try_get_caps(struct ceph_inode_info *ci,
1011-
int need, int want, int *got);
1011+
int need, int want, bool nonblock, int *got);
10121012

10131013
/* for counting open files by mode */
10141014
extern void __ceph_get_fmode(struct ceph_inode_info *ci, int mode);

0 commit comments

Comments
 (0)