Skip to content

Commit fca65b4

Browse files
committed
ceph: do not call __mark_dirty_inode under i_lock
The __mark_dirty_inode helper now takes i_lock as of 250df6e. Fix the one ceph callers that held i_lock (__ceph_mark_dirty_caps) to return the flags value so that the callers can do it outside of i_lock. Signed-off-by: Sage Weil <sage@newdream.net>
1 parent 4ad1262 commit fca65b4

5 files changed

Lines changed: 23 additions & 12 deletions

File tree

‎fs/ceph/caps.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,10 +1331,11 @@ static void ceph_flush_snaps(struct ceph_inode_info *ci)
13311331
}
13321332

13331333
/*
1334-
* Mark caps dirty. If inode is newly dirty, add to the global dirty
1335-
* list.
1334+
* Mark caps dirty. If inode is newly dirty, return the dirty flags.
1335+
* Caller is then responsible for calling __mark_inode_dirty with the
1336+
* returned flags value.
13361337
*/
1337-
void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)
1338+
int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)
13381339
{
13391340
struct ceph_mds_client *mdsc =
13401341
ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc;
@@ -1365,9 +1366,8 @@ void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)
13651366
if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) &&
13661367
(mask & CEPH_CAP_FILE_BUFFER))
13671368
dirty |= I_DIRTY_DATASYNC;
1368-
if (dirty)
1369-
__mark_inode_dirty(inode, dirty);
13701369
__cap_delay_requeue(mdsc, ci);
1370+
return dirty;
13711371
}
13721372

13731373
/*

‎fs/ceph/file.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,12 @@ static ssize_t ceph_aio_write(struct kiocb *iocb, const struct iovec *iov,
734734
}
735735
}
736736
if (ret >= 0) {
737+
int dirty;
737738
spin_lock(&inode->i_lock);
738-
__ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR);
739+
dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_FILE_WR);
739740
spin_unlock(&inode->i_lock);
741+
if (dirty)
742+
__mark_inode_dirty(inode, dirty);
740743
}
741744

742745
out:

‎fs/ceph/inode.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
15671567
int release = 0, dirtied = 0;
15681568
int mask = 0;
15691569
int err = 0;
1570+
int inode_dirty_flags = 0;
15701571

15711572
if (ceph_snap(inode) != CEPH_NOSNAP)
15721573
return -EROFS;
@@ -1725,13 +1726,16 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
17251726
dout("setattr %p ATTR_FILE ... hrm!\n", inode);
17261727

17271728
if (dirtied) {
1728-
__ceph_mark_dirty_caps(ci, dirtied);
1729+
inode_dirty_flags = __ceph_mark_dirty_caps(ci, dirtied);
17291730
inode->i_ctime = CURRENT_TIME;
17301731
}
17311732

17321733
release &= issued;
17331734
spin_unlock(&inode->i_lock);
17341735

1736+
if (inode_dirty_flags)
1737+
__mark_inode_dirty(inode, inode_dirty_flags);
1738+
17351739
if (mask) {
17361740
req->r_inode = igrab(inode);
17371741
req->r_inode_drop = release;

‎fs/ceph/super.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ static inline int __ceph_caps_dirty(struct ceph_inode_info *ci)
506506
{
507507
return ci->i_dirty_caps | ci->i_flushing_caps;
508508
}
509-
extern void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask);
509+
extern int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask);
510510

511511
extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask);
512512
extern int __ceph_caps_used(struct ceph_inode_info *ci);

‎fs/ceph/xattr.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
703703
struct ceph_inode_xattr *xattr = NULL;
704704
int issued;
705705
int required_blob_size;
706+
int dirty;
706707

707708
if (ceph_snap(inode) != CEPH_NOSNAP)
708709
return -EROFS;
@@ -763,11 +764,12 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
763764
dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued));
764765
err = __set_xattr(ci, newname, name_len, newval,
765766
val_len, 1, 1, 1, &xattr);
766-
__ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);
767+
dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);
767768
ci->i_xattrs.dirty = true;
768769
inode->i_ctime = CURRENT_TIME;
769770
spin_unlock(&inode->i_lock);
770-
771+
if (dirty)
772+
__mark_inode_dirty(inode, dirty);
771773
return err;
772774

773775
do_sync:
@@ -810,6 +812,7 @@ int ceph_removexattr(struct dentry *dentry, const char *name)
810812
struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode);
811813
int issued;
812814
int err;
815+
int dirty;
813816

814817
if (ceph_snap(inode) != CEPH_NOSNAP)
815818
return -EROFS;
@@ -833,12 +836,13 @@ int ceph_removexattr(struct dentry *dentry, const char *name)
833836
goto do_sync;
834837

835838
err = __remove_xattr_by_name(ceph_inode(inode), name);
836-
__ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);
839+
dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);
837840
ci->i_xattrs.dirty = true;
838841
inode->i_ctime = CURRENT_TIME;
839842

840843
spin_unlock(&inode->i_lock);
841-
844+
if (dirty)
845+
__mark_inode_dirty(inode, dirty);
842846
return err;
843847
do_sync:
844848
spin_unlock(&inode->i_lock);

0 commit comments

Comments
 (0)