aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-04 17:22:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-04 17:22:20 -0400
commitbd355f8ae6577aa6b444ab76bb1dfeb1a7002d9f (patch)
treeb88b57915ccc335cb1391abf3da5fa59bd5e6ac5
parent1c08232cfe5e68c6234305a3abb64d52d89c9ead (diff)
parentfca65b4ad72d28cbb43a029114d04b89f06faadb (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client: ceph: do not call __mark_dirty_inode under i_lock libceph: fix ceph_osdc_alloc_request error checks ceph: handle ceph_osdc_new_request failure in ceph_writepages_start libceph: fix ceph_msg_new error path ceph: use ihold() when i_lock is held
-rw-r--r--drivers/block/rbd.c4
-rw-r--r--fs/ceph/addr.c7
-rw-r--r--fs/ceph/caps.c14
-rw-r--r--fs/ceph/file.c5
-rw-r--r--fs/ceph/inode.c6
-rw-r--r--fs/ceph/super.h2
-rw-r--r--fs/ceph/xattr.c12
-rw-r--r--net/ceph/messenger.c26
-rw-r--r--net/ceph/osd_client.c4
9 files changed, 49 insertions, 31 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 16dc3645291c..3e904717c1c0 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -777,9 +777,9 @@ static int rbd_do_request(struct request *rq,
777 ops, 777 ops,
778 false, 778 false,
779 GFP_NOIO, pages, bio); 779 GFP_NOIO, pages, bio);
780 if (IS_ERR(req)) { 780 if (!req) {
781 up_read(&header->snap_rwsem); 781 up_read(&header->snap_rwsem);
782 ret = PTR_ERR(req); 782 ret = -ENOMEM;
783 goto done_pages; 783 goto done_pages;
784 } 784 }
785 785
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index e159c529fd2b..38b8ab554924 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -775,6 +775,13 @@ get_more_pages:
775 ci->i_truncate_seq, 775 ci->i_truncate_seq,
776 ci->i_truncate_size, 776 ci->i_truncate_size,
777 &inode->i_mtime, true, 1, 0); 777 &inode->i_mtime, true, 1, 0);
778
779 if (!req) {
780 rc = -ENOMEM;
781 unlock_page(page);
782 break;
783 }
784
778 max_pages = req->r_num_pages; 785 max_pages = req->r_num_pages;
779 786
780 alloc_page_vec(fsc, req); 787 alloc_page_vec(fsc, req);
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 5323c330bbf3..9fa08662a88d 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1331,10 +1331,11 @@ static void ceph_flush_snaps(struct ceph_inode_info *ci)
1331} 1331}
1332 1332
1333/* 1333/*
1334 * Mark caps dirty. If inode is newly dirty, add to the global dirty 1334 * Mark caps dirty. If inode is newly dirty, return the dirty flags.
1335 * list. 1335 * Caller is then responsible for calling __mark_inode_dirty with the
1336 * returned flags value.
1336 */ 1337 */
1337void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask) 1338int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)
1338{ 1339{
1339 struct ceph_mds_client *mdsc = 1340 struct ceph_mds_client *mdsc =
1340 ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; 1341 ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc;
@@ -1357,7 +1358,7 @@ void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)
1357 list_add(&ci->i_dirty_item, &mdsc->cap_dirty); 1358 list_add(&ci->i_dirty_item, &mdsc->cap_dirty);
1358 spin_unlock(&mdsc->cap_dirty_lock); 1359 spin_unlock(&mdsc->cap_dirty_lock);
1359 if (ci->i_flushing_caps == 0) { 1360 if (ci->i_flushing_caps == 0) {
1360 igrab(inode); 1361 ihold(inode);
1361 dirty |= I_DIRTY_SYNC; 1362 dirty |= I_DIRTY_SYNC;
1362 } 1363 }
1363 } 1364 }
@@ -1365,9 +1366,8 @@ void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)
1365 if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) && 1366 if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) &&
1366 (mask & CEPH_CAP_FILE_BUFFER)) 1367 (mask & CEPH_CAP_FILE_BUFFER))
1367 dirty |= I_DIRTY_DATASYNC; 1368 dirty |= I_DIRTY_DATASYNC;
1368 if (dirty)
1369 __mark_inode_dirty(inode, dirty);
1370 __cap_delay_requeue(mdsc, ci); 1369 __cap_delay_requeue(mdsc, ci);
1370 return dirty;
1371} 1371}
1372 1372
1373/* 1373/*
@@ -1991,7 +1991,7 @@ static void __take_cap_refs(struct ceph_inode_info *ci, int got)
1991 ci->i_wr_ref++; 1991 ci->i_wr_ref++;
1992 if (got & CEPH_CAP_FILE_BUFFER) { 1992 if (got & CEPH_CAP_FILE_BUFFER) {
1993 if (ci->i_wrbuffer_ref == 0) 1993 if (ci->i_wrbuffer_ref == 0)
1994 igrab(&ci->vfs_inode); 1994 ihold(&ci->vfs_inode);
1995 ci->i_wrbuffer_ref++; 1995 ci->i_wrbuffer_ref++;
1996 dout("__take_cap_refs %p wrbuffer %d -> %d (?)\n", 1996 dout("__take_cap_refs %p wrbuffer %d -> %d (?)\n",
1997 &ci->vfs_inode, ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref); 1997 &ci->vfs_inode, ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref);
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 159b512d5a27..203252d88d9f 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -734,9 +734,12 @@ retry_snap:
734 } 734 }
735 } 735 }
736 if (ret >= 0) { 736 if (ret >= 0) {
737 int dirty;
737 spin_lock(&inode->i_lock); 738 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);
739 spin_unlock(&inode->i_lock); 740 spin_unlock(&inode->i_lock);
741 if (dirty)
742 __mark_inode_dirty(inode, dirty);
740 } 743 }
741 744
742out: 745out:
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index b54c97da1c43..03d6dafda61f 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1567,6 +1567,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
1567 int release = 0, dirtied = 0; 1567 int release = 0, dirtied = 0;
1568 int mask = 0; 1568 int mask = 0;
1569 int err = 0; 1569 int err = 0;
1570 int inode_dirty_flags = 0;
1570 1571
1571 if (ceph_snap(inode) != CEPH_NOSNAP) 1572 if (ceph_snap(inode) != CEPH_NOSNAP)
1572 return -EROFS; 1573 return -EROFS;
@@ -1725,13 +1726,16 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
1725 dout("setattr %p ATTR_FILE ... hrm!\n", inode); 1726 dout("setattr %p ATTR_FILE ... hrm!\n", inode);
1726 1727
1727 if (dirtied) { 1728 if (dirtied) {
1728 __ceph_mark_dirty_caps(ci, dirtied); 1729 inode_dirty_flags = __ceph_mark_dirty_caps(ci, dirtied);
1729 inode->i_ctime = CURRENT_TIME; 1730 inode->i_ctime = CURRENT_TIME;
1730 } 1731 }
1731 1732
1732 release &= issued; 1733 release &= issued;
1733 spin_unlock(&inode->i_lock); 1734 spin_unlock(&inode->i_lock);
1734 1735
1736 if (inode_dirty_flags)
1737 __mark_inode_dirty(inode, inode_dirty_flags);
1738
1735 if (mask) { 1739 if (mask) {
1736 req->r_inode = igrab(inode); 1740 req->r_inode = igrab(inode);
1737 req->r_inode_drop = release; 1741 req->r_inode_drop = release;
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 619fe719968f..b1f1b8bb1271 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -506,7 +506,7 @@ static inline int __ceph_caps_dirty(struct ceph_inode_info *ci)
506{ 506{
507 return ci->i_dirty_caps | ci->i_flushing_caps; 507 return ci->i_dirty_caps | ci->i_flushing_caps;
508} 508}
509extern void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask); 509extern int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask);
510 510
511extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask); 511extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask);
512extern int __ceph_caps_used(struct ceph_inode_info *ci); 512extern int __ceph_caps_used(struct ceph_inode_info *ci);
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 8c9eba6ef9df..f2b628696180 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -703,6 +703,7 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
703 struct ceph_inode_xattr *xattr = NULL; 703 struct ceph_inode_xattr *xattr = NULL;
704 int issued; 704 int issued;
705 int required_blob_size; 705 int required_blob_size;
706 int dirty;
706 707
707 if (ceph_snap(inode) != CEPH_NOSNAP) 708 if (ceph_snap(inode) != CEPH_NOSNAP)
708 return -EROFS; 709 return -EROFS;
@@ -763,11 +764,12 @@ retry:
763 dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued)); 764 dout("setxattr %p issued %s\n", inode, ceph_cap_string(issued));
764 err = __set_xattr(ci, newname, name_len, newval, 765 err = __set_xattr(ci, newname, name_len, newval,
765 val_len, 1, 1, 1, &xattr); 766 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);
767 ci->i_xattrs.dirty = true; 768 ci->i_xattrs.dirty = true;
768 inode->i_ctime = CURRENT_TIME; 769 inode->i_ctime = CURRENT_TIME;
769 spin_unlock(&inode->i_lock); 770 spin_unlock(&inode->i_lock);
770 771 if (dirty)
772 __mark_inode_dirty(inode, dirty);
771 return err; 773 return err;
772 774
773do_sync: 775do_sync:
@@ -810,6 +812,7 @@ int ceph_removexattr(struct dentry *dentry, const char *name)
810 struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode); 812 struct ceph_vxattr_cb *vxattrs = ceph_inode_vxattrs(inode);
811 int issued; 813 int issued;
812 int err; 814 int err;
815 int dirty;
813 816
814 if (ceph_snap(inode) != CEPH_NOSNAP) 817 if (ceph_snap(inode) != CEPH_NOSNAP)
815 return -EROFS; 818 return -EROFS;
@@ -833,12 +836,13 @@ int ceph_removexattr(struct dentry *dentry, const char *name)
833 goto do_sync; 836 goto do_sync;
834 837
835 err = __remove_xattr_by_name(ceph_inode(inode), name); 838 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);
837 ci->i_xattrs.dirty = true; 840 ci->i_xattrs.dirty = true;
838 inode->i_ctime = CURRENT_TIME; 841 inode->i_ctime = CURRENT_TIME;
839 842
840 spin_unlock(&inode->i_lock); 843 spin_unlock(&inode->i_lock);
841 844 if (dirty)
845 __mark_inode_dirty(inode, dirty);
842 return err; 846 return err;
843do_sync: 847do_sync:
844 spin_unlock(&inode->i_lock); 848 spin_unlock(&inode->i_lock);
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 05f357828a2f..e15a82ccc05f 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2267,6 +2267,19 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags)
2267 m->more_to_follow = false; 2267 m->more_to_follow = false;
2268 m->pool = NULL; 2268 m->pool = NULL;
2269 2269
2270 /* middle */
2271 m->middle = NULL;
2272
2273 /* data */
2274 m->nr_pages = 0;
2275 m->page_alignment = 0;
2276 m->pages = NULL;
2277 m->pagelist = NULL;
2278 m->bio = NULL;
2279 m->bio_iter = NULL;
2280 m->bio_seg = 0;
2281 m->trail = NULL;
2282
2270 /* front */ 2283 /* front */
2271 if (front_len) { 2284 if (front_len) {
2272 if (front_len > PAGE_CACHE_SIZE) { 2285 if (front_len > PAGE_CACHE_SIZE) {
@@ -2286,19 +2299,6 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags)
2286 } 2299 }
2287 m->front.iov_len = front_len; 2300 m->front.iov_len = front_len;
2288 2301
2289 /* middle */
2290 m->middle = NULL;
2291
2292 /* data */
2293 m->nr_pages = 0;
2294 m->page_alignment = 0;
2295 m->pages = NULL;
2296 m->pagelist = NULL;
2297 m->bio = NULL;
2298 m->bio_iter = NULL;
2299 m->bio_seg = 0;
2300 m->trail = NULL;
2301
2302 dout("ceph_msg_new %p front %d\n", m, front_len); 2302 dout("ceph_msg_new %p front %d\n", m, front_len);
2303 return m; 2303 return m;
2304 2304
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 5a80f41c0cba..6b5dda1cb5df 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -470,8 +470,8 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
470 snapc, ops, 470 snapc, ops,
471 use_mempool, 471 use_mempool,
472 GFP_NOFS, NULL, NULL); 472 GFP_NOFS, NULL, NULL);
473 if (IS_ERR(req)) 473 if (!req)
474 return req; 474 return NULL;
475 475
476 /* calculate max write size */ 476 /* calculate max write size */
477 calc_layout(osdc, vino, layout, off, plen, req, ops); 477 calc_layout(osdc, vino, layout, off, plen, req, ops);