1334
* Mark caps dirty. If inode is newly dirty, add to the global dirty
1335
* Mark caps dirty. If inode is newly dirty, return the dirty flags.
1336
* Caller is then responsible for calling __mark_inode_dirty with the
1337
* returned flags value.
1337
void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)
1339
int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)
1339
1341
struct ceph_mds_client *mdsc =
1340
1342
ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc;
1365
1367
if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) &&
1366
1368
(mask & CEPH_CAP_FILE_BUFFER))
1367
1369
dirty |= I_DIRTY_DATASYNC;
1369
__mark_inode_dirty(inode, dirty);
1370
1370
__cap_delay_requeue(mdsc, ci);
1990
1991
if (got & CEPH_CAP_FILE_WR)
1991
1992
ci->i_wr_ref++;
1992
1993
if (got & CEPH_CAP_FILE_BUFFER) {
1993
if (ci->i_wrbuffer_ref == 0)
1994
igrab(&ci->vfs_inode);
1995
ci->i_wrbuffer_ref++;
1996
dout("__take_cap_refs %p wrbuffer %d -> %d (?)\n",
1997
&ci->vfs_inode, ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref);
1994
if (ci->i_wb_ref == 0)
1995
ihold(&ci->vfs_inode);
1997
dout("__take_cap_refs %p wb %d -> %d (?)\n",
1998
&ci->vfs_inode, ci->i_wb_ref-1, ci->i_wb_ref);
2169
2170
if (--ci->i_rdcache_ref == 0)
2171
2172
if (had & CEPH_CAP_FILE_BUFFER) {
2172
if (--ci->i_wrbuffer_ref == 0) {
2173
if (--ci->i_wb_ref == 0) {
2176
dout("put_cap_refs %p wrbuffer %d -> %d (?)\n",
2177
inode, ci->i_wrbuffer_ref+1, ci->i_wrbuffer_ref);
2177
dout("put_cap_refs %p wb %d -> %d (?)\n",
2178
inode, ci->i_wb_ref+1, ci->i_wb_ref);
2179
2180
if (had & CEPH_CAP_FILE_WR)
2180
2181
if (--ci->i_wr_ref == 0) {
2634
2635
struct ceph_mds_session *session,
2635
2636
int *open_target_sessions)
2638
struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
2637
2639
struct ceph_inode_info *ci = ceph_inode(inode);
2638
2640
int mds = session->s_mds;
2639
2641
unsigned mseq = le32_to_cpu(ex->migrate_seq);
2670
2672
* export targets, so that we get the matching IMPORT
2672
2674
*open_target_sessions = 1;
2677
* we can't flush dirty caps that we've seen the
2678
* EXPORT but no IMPORT for
2680
spin_lock(&mdsc->cap_dirty_lock);
2681
if (!list_empty(&ci->i_dirty_item)) {
2682
dout(" moving %p to cap_dirty_migrating\n",
2684
list_move(&ci->i_dirty_item,
2685
&mdsc->cap_dirty_migrating);
2687
spin_unlock(&mdsc->cap_dirty_lock);
2674
2689
__ceph_remove_cap(cap);
2707
2722
ci->i_cap_exporting_issued = 0;
2708
2723
ci->i_cap_exporting_mseq = 0;
2709
2724
ci->i_cap_exporting_mds = -1;
2726
spin_lock(&mdsc->cap_dirty_lock);
2727
if (!list_empty(&ci->i_dirty_item)) {
2728
dout(" moving %p back to cap_dirty\n", inode);
2729
list_move(&ci->i_dirty_item, &mdsc->cap_dirty);
2731
spin_unlock(&mdsc->cap_dirty_lock);
2711
2733
dout("handle_cap_import inode %p ci %p mds%d mseq %d\n",
2712
2734
inode, ci, mds, mseq);
2911
2933
void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc)
2913
struct ceph_inode_info *ci, *nci = NULL;
2914
struct inode *inode, *ninode = NULL;
2915
struct list_head *p, *n;
2935
struct ceph_inode_info *ci;
2936
struct inode *inode;
2917
2938
dout("flush_dirty_caps\n");
2918
2939
spin_lock(&mdsc->cap_dirty_lock);
2919
list_for_each_safe(p, n, &mdsc->cap_dirty) {
2923
ci->i_ceph_flags &= ~CEPH_I_NOFLUSH;
2924
dout("flush_dirty_caps inode %p (was next inode)\n",
2927
ci = list_entry(p, struct ceph_inode_info,
2929
inode = igrab(&ci->vfs_inode);
2931
dout("flush_dirty_caps inode %p\n", inode);
2933
if (n != &mdsc->cap_dirty) {
2934
nci = list_entry(n, struct ceph_inode_info,
2936
ninode = igrab(&nci->vfs_inode);
2938
nci->i_ceph_flags |= CEPH_I_NOFLUSH;
2939
dout("flush_dirty_caps next inode %p, noflush\n",
2940
while (!list_empty(&mdsc->cap_dirty)) {
2941
ci = list_first_entry(&mdsc->cap_dirty, struct ceph_inode_info,
2943
inode = &ci->vfs_inode;
2945
dout("flush_dirty_caps %p\n", inode);
2945
2946
spin_unlock(&mdsc->cap_dirty_lock);
2947
ceph_check_caps(ci, CHECK_CAPS_NODELAY|CHECK_CAPS_FLUSH,
2947
ceph_check_caps(ci, CHECK_CAPS_NODELAY|CHECK_CAPS_FLUSH, NULL);
2951
2949
spin_lock(&mdsc->cap_dirty_lock);
2953
2951
spin_unlock(&mdsc->cap_dirty_lock);
2952
dout("flush_dirty_caps done\n");