Commit efb0ca76 authored by Yan, Zheng's avatar Yan, Zheng Committed by Ilya Dryomov

ceph: update the 'approaching max_size' code

The old 'approaching max_size' code expects MDS set max_size to
'2 * reported_size'. This is no longer true. The new code reports
file size when half of previous max_size increment has been used.
Signed-off-by: default avatar"Yan, Zheng" <zyan@redhat.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 84eea8c7
...@@ -1318,7 +1318,7 @@ static int ceph_write_end(struct file *file, struct address_space *mapping, ...@@ -1318,7 +1318,7 @@ static int ceph_write_end(struct file *file, struct address_space *mapping,
struct page *page, void *fsdata) struct page *page, void *fsdata)
{ {
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
int check_cap = 0; bool check_cap = false;
dout("write_end file %p inode %p page %p %d~%d (%d)\n", file, dout("write_end file %p inode %p page %p %d~%d (%d)\n", file,
inode, page, (int)pos, (int)copied, (int)len); inode, page, (int)pos, (int)copied, (int)len);
......
...@@ -1653,6 +1653,21 @@ static int try_nonblocking_invalidate(struct inode *inode) ...@@ -1653,6 +1653,21 @@ static int try_nonblocking_invalidate(struct inode *inode)
return -1; return -1;
} }
bool __ceph_should_report_size(struct ceph_inode_info *ci)
{
loff_t size = ci->vfs_inode.i_size;
/* mds will adjust max size according to the reported size */
if (ci->i_flushing_caps & CEPH_CAP_FILE_WR)
return false;
if (size >= ci->i_max_size)
return true;
/* half of previous max_size increment has been used */
if (ci->i_max_size > ci->i_reported_size &&
(size << 1) >= ci->i_max_size + ci->i_reported_size)
return true;
return false;
}
/* /*
* Swiss army knife function to examine currently used and wanted * Swiss army knife function to examine currently used and wanted
* versus held caps. Release, flush, ack revoked caps to mds as * versus held caps. Release, flush, ack revoked caps to mds as
...@@ -1806,8 +1821,7 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags, ...@@ -1806,8 +1821,7 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
} }
/* approaching file_max? */ /* approaching file_max? */
if ((inode->i_size << 1) >= ci->i_max_size && if (__ceph_should_report_size(ci)) {
(ci->i_reported_size << 1) < ci->i_max_size) {
dout("i_size approaching max_size\n"); dout("i_size approaching max_size\n");
goto ack; goto ack;
} }
......
...@@ -1040,8 +1040,8 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos, ...@@ -1040,8 +1040,8 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
int num_pages; int num_pages;
int written = 0; int written = 0;
int flags; int flags;
int check_caps = 0;
int ret; int ret;
bool check_caps = false;
struct timespec mtime = current_time(inode); struct timespec mtime = current_time(inode);
size_t count = iov_iter_count(from); size_t count = iov_iter_count(from);
......
...@@ -1653,20 +1653,17 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req, ...@@ -1653,20 +1653,17 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req,
return err; return err;
} }
int ceph_inode_set_size(struct inode *inode, loff_t size) bool ceph_inode_set_size(struct inode *inode, loff_t size)
{ {
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
int ret = 0; bool ret;
spin_lock(&ci->i_ceph_lock); spin_lock(&ci->i_ceph_lock);
dout("set_size %p %llu -> %llu\n", inode, inode->i_size, size); dout("set_size %p %llu -> %llu\n", inode, inode->i_size, size);
i_size_write(inode, size); i_size_write(inode, size);
inode->i_blocks = calc_inode_blocks(size); inode->i_blocks = calc_inode_blocks(size);
/* tell the MDS if we are approaching max_size */ ret = __ceph_should_report_size(ci);
if ((size << 1) >= ci->i_max_size &&
(ci->i_reported_size << 1) < ci->i_max_size)
ret = 1;
spin_unlock(&ci->i_ceph_lock); spin_unlock(&ci->i_ceph_lock);
return ret; return ret;
......
...@@ -793,7 +793,7 @@ extern int ceph_readdir_prepopulate(struct ceph_mds_request *req, ...@@ -793,7 +793,7 @@ extern int ceph_readdir_prepopulate(struct ceph_mds_request *req,
extern int ceph_inode_holds_cap(struct inode *inode, int mask); extern int ceph_inode_holds_cap(struct inode *inode, int mask);
extern int ceph_inode_set_size(struct inode *inode, loff_t size); extern bool ceph_inode_set_size(struct inode *inode, loff_t size);
extern void __ceph_do_pending_vmtruncate(struct inode *inode); extern void __ceph_do_pending_vmtruncate(struct inode *inode);
extern void ceph_queue_vmtruncate(struct inode *inode); extern void ceph_queue_vmtruncate(struct inode *inode);
...@@ -918,6 +918,7 @@ extern void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr, ...@@ -918,6 +918,7 @@ extern void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
struct ceph_snap_context *snapc); struct ceph_snap_context *snapc);
extern void ceph_flush_snaps(struct ceph_inode_info *ci, extern void ceph_flush_snaps(struct ceph_inode_info *ci,
struct ceph_mds_session **psession); struct ceph_mds_session **psession);
extern bool __ceph_should_report_size(struct ceph_inode_info *ci);
extern void ceph_check_caps(struct ceph_inode_info *ci, int flags, extern void ceph_check_caps(struct ceph_inode_info *ci, int flags,
struct ceph_mds_session *session); struct ceph_mds_session *session);
extern void ceph_check_delayed_caps(struct ceph_mds_client *mdsc); extern void ceph_check_delayed_caps(struct ceph_mds_client *mdsc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment