aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2017-02-13 08:44:19 -0500
committerIlya Dryomov <idryomov@gmail.com>2017-02-24 13:04:57 -0500
commit55f2a04588c5881d90e22631b17a84cd25d17cc4 (patch)
tree6dc9b01395ba83ff443d3eb5d4cb3cde39534003
parentf107548039807eb890e65ce5cd29d6ac52562f09 (diff)
ceph: remove special ack vs commit behavior
- ask for a commit reply instead of an ack reply in __ceph_pool_perm_get() - don't ask for both ack and commit replies in ceph_sync_write() - since just only one reply is requested now, i_unsafe_writes list will always be empty -- kill ceph_sync_write_wait() and go back to a standard ->evict_inode() Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Sage Weil <sage@redhat.com>
-rw-r--r--fs/ceph/addr.c2
-rw-r--r--fs/ceph/caps.c2
-rw-r--r--fs/ceph/file.c88
-rw-r--r--fs/ceph/inode.c9
-rw-r--r--fs/ceph/super.c1
-rw-r--r--fs/ceph/super.h4
6 files changed, 3 insertions, 103 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 4547bbf80e4f..3f0474c55f05 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1872,7 +1872,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci,
1872 goto out_unlock; 1872 goto out_unlock;
1873 } 1873 }
1874 1874
1875 wr_req->r_flags = CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ACK; 1875 wr_req->r_flags = CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK;
1876 osd_req_op_init(wr_req, 0, CEPH_OSD_OP_CREATE, CEPH_OSD_OP_FLAG_EXCL); 1876 osd_req_op_init(wr_req, 0, CEPH_OSD_OP_CREATE, CEPH_OSD_OP_FLAG_EXCL);
1877 ceph_oloc_copy(&wr_req->r_base_oloc, &rd_req->r_base_oloc); 1877 ceph_oloc_copy(&wr_req->r_base_oloc, &rd_req->r_base_oloc);
1878 ceph_oid_copy(&wr_req->r_base_oid, &rd_req->r_base_oid); 1878 ceph_oid_copy(&wr_req->r_base_oid, &rd_req->r_base_oid);
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 3c2dfd72e5b2..cd966f276a8d 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2091,8 +2091,6 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
2091 2091
2092 dout("fsync %p%s\n", inode, datasync ? " datasync" : ""); 2092 dout("fsync %p%s\n", inode, datasync ? " datasync" : "");
2093 2093
2094 ceph_sync_write_wait(inode);
2095
2096 ret = filemap_write_and_wait_range(inode->i_mapping, start, end); 2094 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
2097 if (ret < 0) 2095 if (ret < 0)
2098 goto out; 2096 goto out;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index baad3b688ada..023cb7fd9b5f 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -795,89 +795,6 @@ out:
795 kfree(aio_work); 795 kfree(aio_work);
796} 796}
797 797
798/*
799 * Write commit request unsafe callback, called to tell us when a
800 * request is unsafe (that is, in flight--has been handed to the
801 * messenger to send to its target osd). It is called again when
802 * we've received a response message indicating the request is
803 * "safe" (its CEPH_OSD_FLAG_ONDISK flag is set), or when a request
804 * is completed early (and unsuccessfully) due to a timeout or
805 * interrupt.
806 *
807 * This is used if we requested both an ACK and ONDISK commit reply
808 * from the OSD.
809 */
810static void ceph_sync_write_unsafe(struct ceph_osd_request *req, bool unsafe)
811{
812 struct ceph_inode_info *ci = ceph_inode(req->r_inode);
813
814 dout("%s %p tid %llu %ssafe\n", __func__, req, req->r_tid,
815 unsafe ? "un" : "");
816 if (unsafe) {
817 ceph_get_cap_refs(ci, CEPH_CAP_FILE_WR);
818 spin_lock(&ci->i_unsafe_lock);
819 list_add_tail(&req->r_unsafe_item,
820 &ci->i_unsafe_writes);
821 spin_unlock(&ci->i_unsafe_lock);
822
823 complete_all(&req->r_completion);
824 } else {
825 spin_lock(&ci->i_unsafe_lock);
826 list_del_init(&req->r_unsafe_item);
827 spin_unlock(&ci->i_unsafe_lock);
828 ceph_put_cap_refs(ci, CEPH_CAP_FILE_WR);
829 }
830}
831
832/*
833 * Wait on any unsafe replies for the given inode. First wait on the
834 * newest request, and make that the upper bound. Then, if there are
835 * more requests, keep waiting on the oldest as long as it is still older
836 * than the original request.
837 */
838void ceph_sync_write_wait(struct inode *inode)
839{
840 struct ceph_inode_info *ci = ceph_inode(inode);
841 struct list_head *head = &ci->i_unsafe_writes;
842 struct ceph_osd_request *req;
843 u64 last_tid;
844
845 if (!S_ISREG(inode->i_mode))
846 return;
847
848 spin_lock(&ci->i_unsafe_lock);
849 if (list_empty(head))
850 goto out;
851
852 /* set upper bound as _last_ entry in chain */
853
854 req = list_last_entry(head, struct ceph_osd_request,
855 r_unsafe_item);
856 last_tid = req->r_tid;
857
858 do {
859 ceph_osdc_get_request(req);
860 spin_unlock(&ci->i_unsafe_lock);
861
862 dout("sync_write_wait on tid %llu (until %llu)\n",
863 req->r_tid, last_tid);
864 wait_for_completion(&req->r_done_completion);
865 ceph_osdc_put_request(req);
866
867 spin_lock(&ci->i_unsafe_lock);
868 /*
869 * from here on look at first entry in chain, since we
870 * only want to wait for anything older than last_tid
871 */
872 if (list_empty(head))
873 break;
874 req = list_first_entry(head, struct ceph_osd_request,
875 r_unsafe_item);
876 } while (req->r_tid < last_tid);
877out:
878 spin_unlock(&ci->i_unsafe_lock);
879}
880
881static ssize_t 798static ssize_t
882ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter, 799ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
883 struct ceph_snap_context *snapc, 800 struct ceph_snap_context *snapc,
@@ -1119,8 +1036,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
1119 1036
1120 flags = CEPH_OSD_FLAG_ORDERSNAP | 1037 flags = CEPH_OSD_FLAG_ORDERSNAP |
1121 CEPH_OSD_FLAG_ONDISK | 1038 CEPH_OSD_FLAG_ONDISK |
1122 CEPH_OSD_FLAG_WRITE | 1039 CEPH_OSD_FLAG_WRITE;
1123 CEPH_OSD_FLAG_ACK;
1124 1040
1125 while ((len = iov_iter_count(from)) > 0) { 1041 while ((len = iov_iter_count(from)) > 0) {
1126 size_t left; 1042 size_t left;
@@ -1166,8 +1082,6 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
1166 goto out; 1082 goto out;
1167 } 1083 }
1168 1084
1169 /* get a second commit callback */
1170 req->r_unsafe_callback = ceph_sync_write_unsafe;
1171 req->r_inode = inode; 1085 req->r_inode = inode;
1172 1086
1173 osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0, 1087 osd_req_op_extent_osd_data_pages(req, 0, pages, len, 0,
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 68f46132b157..fd8f771f99b7 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -499,7 +499,6 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
499 ci->i_rdcache_gen = 0; 499 ci->i_rdcache_gen = 0;
500 ci->i_rdcache_revoking = 0; 500 ci->i_rdcache_revoking = 0;
501 501
502 INIT_LIST_HEAD(&ci->i_unsafe_writes);
503 INIT_LIST_HEAD(&ci->i_unsafe_dirops); 502 INIT_LIST_HEAD(&ci->i_unsafe_dirops);
504 INIT_LIST_HEAD(&ci->i_unsafe_iops); 503 INIT_LIST_HEAD(&ci->i_unsafe_iops);
505 spin_lock_init(&ci->i_unsafe_lock); 504 spin_lock_init(&ci->i_unsafe_lock);
@@ -583,14 +582,6 @@ int ceph_drop_inode(struct inode *inode)
583 return 1; 582 return 1;
584} 583}
585 584
586void ceph_evict_inode(struct inode *inode)
587{
588 /* wait unsafe sync writes */
589 ceph_sync_write_wait(inode);
590 truncate_inode_pages_final(&inode->i_data);
591 clear_inode(inode);
592}
593
594static inline blkcnt_t calc_inode_blocks(u64 size) 585static inline blkcnt_t calc_inode_blocks(u64 size)
595{ 586{
596 return (size + (1<<9) - 1) >> 9; 587 return (size + (1<<9) - 1) >> 9;
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index a0a0b6d02f89..0ec8d0114e57 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -757,7 +757,6 @@ static const struct super_operations ceph_super_ops = {
757 .destroy_inode = ceph_destroy_inode, 757 .destroy_inode = ceph_destroy_inode,
758 .write_inode = ceph_write_inode, 758 .write_inode = ceph_write_inode,
759 .drop_inode = ceph_drop_inode, 759 .drop_inode = ceph_drop_inode,
760 .evict_inode = ceph_evict_inode,
761 .sync_fs = ceph_sync_fs, 760 .sync_fs = ceph_sync_fs,
762 .put_super = ceph_put_super, 761 .put_super = ceph_put_super,
763 .show_options = ceph_show_options, 762 .show_options = ceph_show_options,
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 950170136be9..e9410bcf4113 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -343,7 +343,6 @@ struct ceph_inode_info {
343 u32 i_rdcache_gen; /* incremented each time we get FILE_CACHE. */ 343 u32 i_rdcache_gen; /* incremented each time we get FILE_CACHE. */
344 u32 i_rdcache_revoking; /* RDCACHE gen to async invalidate, if any */ 344 u32 i_rdcache_revoking; /* RDCACHE gen to async invalidate, if any */
345 345
346 struct list_head i_unsafe_writes; /* uncommitted sync writes */
347 struct list_head i_unsafe_dirops; /* uncommitted mds dir ops */ 346 struct list_head i_unsafe_dirops; /* uncommitted mds dir ops */
348 struct list_head i_unsafe_iops; /* uncommitted mds inode ops */ 347 struct list_head i_unsafe_iops; /* uncommitted mds inode ops */
349 spinlock_t i_unsafe_lock; 348 spinlock_t i_unsafe_lock;
@@ -753,7 +752,6 @@ extern const struct inode_operations ceph_file_iops;
753extern struct inode *ceph_alloc_inode(struct super_block *sb); 752extern struct inode *ceph_alloc_inode(struct super_block *sb);
754extern void ceph_destroy_inode(struct inode *inode); 753extern void ceph_destroy_inode(struct inode *inode);
755extern int ceph_drop_inode(struct inode *inode); 754extern int ceph_drop_inode(struct inode *inode);
756extern void ceph_evict_inode(struct inode *inode);
757 755
758extern struct inode *ceph_get_inode(struct super_block *sb, 756extern struct inode *ceph_get_inode(struct super_block *sb,
759 struct ceph_vino vino); 757 struct ceph_vino vino);
@@ -933,7 +931,7 @@ extern int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
933extern int ceph_release(struct inode *inode, struct file *filp); 931extern int ceph_release(struct inode *inode, struct file *filp);
934extern void ceph_fill_inline_data(struct inode *inode, struct page *locked_page, 932extern void ceph_fill_inline_data(struct inode *inode, struct page *locked_page,
935 char *data, size_t len); 933 char *data, size_t len);
936extern void ceph_sync_write_wait(struct inode *inode); 934
937/* dir.c */ 935/* dir.c */
938extern const struct file_operations ceph_dir_fops; 936extern const struct file_operations ceph_dir_fops;
939extern const struct file_operations ceph_snapdir_fops; 937extern const struct file_operations ceph_snapdir_fops;