浏览代码

ceph: adding new return type vm_fault_t

Use new return type vm_fault_t for page_mkwrite
and fault handler.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Souptick Joarder 7 年之前
父节点
当前提交
24499847e4
共有 1 个文件被更改,包括 32 次插入30 次删除
  1. 32 30
      fs/ceph/addr.c

+ 32 - 30
fs/ceph/addr.c

@@ -1429,7 +1429,7 @@ static void ceph_restore_sigs(sigset_t *oldset)
 /*
 /*
  * vm ops
  * vm ops
  */
  */
-static int ceph_filemap_fault(struct vm_fault *vmf)
+static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf)
 {
 {
 	struct vm_area_struct *vma = vmf->vma;
 	struct vm_area_struct *vma = vmf->vma;
 	struct inode *inode = file_inode(vma->vm_file);
 	struct inode *inode = file_inode(vma->vm_file);
@@ -1437,8 +1437,9 @@ static int ceph_filemap_fault(struct vm_fault *vmf)
 	struct ceph_file_info *fi = vma->vm_file->private_data;
 	struct ceph_file_info *fi = vma->vm_file->private_data;
 	struct page *pinned_page = NULL;
 	struct page *pinned_page = NULL;
 	loff_t off = vmf->pgoff << PAGE_SHIFT;
 	loff_t off = vmf->pgoff << PAGE_SHIFT;
-	int want, got, ret;
+	int want, got, err;
 	sigset_t oldset;
 	sigset_t oldset;
+	vm_fault_t ret = VM_FAULT_SIGBUS;
 
 
 	ceph_block_sigs(&oldset);
 	ceph_block_sigs(&oldset);
 
 
@@ -1450,8 +1451,8 @@ static int ceph_filemap_fault(struct vm_fault *vmf)
 		want = CEPH_CAP_FILE_CACHE;
 		want = CEPH_CAP_FILE_CACHE;
 
 
 	got = 0;
 	got = 0;
-	ret = ceph_get_caps(ci, CEPH_CAP_FILE_RD, want, -1, &got, &pinned_page);
-	if (ret < 0)
+	err = ceph_get_caps(ci, CEPH_CAP_FILE_RD, want, -1, &got, &pinned_page);
+	if (err < 0)
 		goto out_restore;
 		goto out_restore;
 
 
 	dout("filemap_fault %p %llu~%zd got cap refs on %s\n",
 	dout("filemap_fault %p %llu~%zd got cap refs on %s\n",
@@ -1463,16 +1464,17 @@ static int ceph_filemap_fault(struct vm_fault *vmf)
 		ceph_add_rw_context(fi, &rw_ctx);
 		ceph_add_rw_context(fi, &rw_ctx);
 		ret = filemap_fault(vmf);
 		ret = filemap_fault(vmf);
 		ceph_del_rw_context(fi, &rw_ctx);
 		ceph_del_rw_context(fi, &rw_ctx);
+		dout("filemap_fault %p %llu~%zd drop cap refs %s ret %x\n",
+			inode, off, (size_t)PAGE_SIZE,
+				ceph_cap_string(got), ret);
 	} else
 	} else
-		ret = -EAGAIN;
+		err = -EAGAIN;
 
 
-	dout("filemap_fault %p %llu~%zd dropping cap refs on %s ret %d\n",
-	     inode, off, (size_t)PAGE_SIZE, ceph_cap_string(got), ret);
 	if (pinned_page)
 	if (pinned_page)
 		put_page(pinned_page);
 		put_page(pinned_page);
 	ceph_put_cap_refs(ci, got);
 	ceph_put_cap_refs(ci, got);
 
 
-	if (ret != -EAGAIN)
+	if (err != -EAGAIN)
 		goto out_restore;
 		goto out_restore;
 
 
 	/* read inline data */
 	/* read inline data */
@@ -1480,7 +1482,6 @@ static int ceph_filemap_fault(struct vm_fault *vmf)
 		/* does not support inline data > PAGE_SIZE */
 		/* does not support inline data > PAGE_SIZE */
 		ret = VM_FAULT_SIGBUS;
 		ret = VM_FAULT_SIGBUS;
 	} else {
 	} else {
-		int ret1;
 		struct address_space *mapping = inode->i_mapping;
 		struct address_space *mapping = inode->i_mapping;
 		struct page *page = find_or_create_page(mapping, 0,
 		struct page *page = find_or_create_page(mapping, 0,
 						mapping_gfp_constraint(mapping,
 						mapping_gfp_constraint(mapping,
@@ -1489,32 +1490,32 @@ static int ceph_filemap_fault(struct vm_fault *vmf)
 			ret = VM_FAULT_OOM;
 			ret = VM_FAULT_OOM;
 			goto out_inline;
 			goto out_inline;
 		}
 		}
-		ret1 = __ceph_do_getattr(inode, page,
+		err = __ceph_do_getattr(inode, page,
 					 CEPH_STAT_CAP_INLINE_DATA, true);
 					 CEPH_STAT_CAP_INLINE_DATA, true);
-		if (ret1 < 0 || off >= i_size_read(inode)) {
+		if (err < 0 || off >= i_size_read(inode)) {
 			unlock_page(page);
 			unlock_page(page);
 			put_page(page);
 			put_page(page);
-			if (ret1 < 0)
-				ret = ret1;
+			if (err == -ENOMEM)
+				ret = VM_FAULT_OOM;
 			else
 			else
 				ret = VM_FAULT_SIGBUS;
 				ret = VM_FAULT_SIGBUS;
 			goto out_inline;
 			goto out_inline;
 		}
 		}
-		if (ret1 < PAGE_SIZE)
-			zero_user_segment(page, ret1, PAGE_SIZE);
+		if (err < PAGE_SIZE)
+			zero_user_segment(page, err, PAGE_SIZE);
 		else
 		else
 			flush_dcache_page(page);
 			flush_dcache_page(page);
 		SetPageUptodate(page);
 		SetPageUptodate(page);
 		vmf->page = page;
 		vmf->page = page;
 		ret = VM_FAULT_MAJOR | VM_FAULT_LOCKED;
 		ret = VM_FAULT_MAJOR | VM_FAULT_LOCKED;
 out_inline:
 out_inline:
-		dout("filemap_fault %p %llu~%zd read inline data ret %d\n",
+		dout("filemap_fault %p %llu~%zd read inline data ret %x\n",
 		     inode, off, (size_t)PAGE_SIZE, ret);
 		     inode, off, (size_t)PAGE_SIZE, ret);
 	}
 	}
 out_restore:
 out_restore:
 	ceph_restore_sigs(&oldset);
 	ceph_restore_sigs(&oldset);
-	if (ret < 0)
-		ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS;
+	if (err < 0)
+		ret = vmf_error(err);
 
 
 	return ret;
 	return ret;
 }
 }
@@ -1522,7 +1523,7 @@ out_restore:
 /*
 /*
  * Reuse write_begin here for simplicity.
  * Reuse write_begin here for simplicity.
  */
  */
-static int ceph_page_mkwrite(struct vm_fault *vmf)
+static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)
 {
 {
 	struct vm_area_struct *vma = vmf->vma;
 	struct vm_area_struct *vma = vmf->vma;
 	struct inode *inode = file_inode(vma->vm_file);
 	struct inode *inode = file_inode(vma->vm_file);
@@ -1533,8 +1534,9 @@ static int ceph_page_mkwrite(struct vm_fault *vmf)
 	loff_t off = page_offset(page);
 	loff_t off = page_offset(page);
 	loff_t size = i_size_read(inode);
 	loff_t size = i_size_read(inode);
 	size_t len;
 	size_t len;
-	int want, got, ret;
+	int want, got, err;
 	sigset_t oldset;
 	sigset_t oldset;
+	vm_fault_t ret = VM_FAULT_SIGBUS;
 
 
 	prealloc_cf = ceph_alloc_cap_flush();
 	prealloc_cf = ceph_alloc_cap_flush();
 	if (!prealloc_cf)
 	if (!prealloc_cf)
@@ -1548,10 +1550,10 @@ static int ceph_page_mkwrite(struct vm_fault *vmf)
 			lock_page(page);
 			lock_page(page);
 			locked_page = page;
 			locked_page = page;
 		}
 		}
-		ret = ceph_uninline_data(vma->vm_file, locked_page);
+		err = ceph_uninline_data(vma->vm_file, locked_page);
 		if (locked_page)
 		if (locked_page)
 			unlock_page(locked_page);
 			unlock_page(locked_page);
-		if (ret < 0)
+		if (err < 0)
 			goto out_free;
 			goto out_free;
 	}
 	}
 
 
@@ -1568,9 +1570,9 @@ static int ceph_page_mkwrite(struct vm_fault *vmf)
 		want = CEPH_CAP_FILE_BUFFER;
 		want = CEPH_CAP_FILE_BUFFER;
 
 
 	got = 0;
 	got = 0;
-	ret = ceph_get_caps(ci, CEPH_CAP_FILE_WR, want, off + len,
+	err = ceph_get_caps(ci, CEPH_CAP_FILE_WR, want, off + len,
 			    &got, NULL);
 			    &got, NULL);
-	if (ret < 0)
+	if (err < 0)
 		goto out_free;
 		goto out_free;
 
 
 	dout("page_mkwrite %p %llu~%zd got cap refs on %s\n",
 	dout("page_mkwrite %p %llu~%zd got cap refs on %s\n",
@@ -1588,13 +1590,13 @@ static int ceph_page_mkwrite(struct vm_fault *vmf)
 			break;
 			break;
 		}
 		}
 
 
-		ret = ceph_update_writeable_page(vma->vm_file, off, len, page);
-		if (ret >= 0) {
+		err = ceph_update_writeable_page(vma->vm_file, off, len, page);
+		if (err >= 0) {
 			/* success.  we'll keep the page locked. */
 			/* success.  we'll keep the page locked. */
 			set_page_dirty(page);
 			set_page_dirty(page);
 			ret = VM_FAULT_LOCKED;
 			ret = VM_FAULT_LOCKED;
 		}
 		}
-	} while (ret == -EAGAIN);
+	} while (err == -EAGAIN);
 
 
 	if (ret == VM_FAULT_LOCKED ||
 	if (ret == VM_FAULT_LOCKED ||
 	    ci->i_inline_version != CEPH_INLINE_NONE) {
 	    ci->i_inline_version != CEPH_INLINE_NONE) {
@@ -1608,14 +1610,14 @@ static int ceph_page_mkwrite(struct vm_fault *vmf)
 			__mark_inode_dirty(inode, dirty);
 			__mark_inode_dirty(inode, dirty);
 	}
 	}
 
 
-	dout("page_mkwrite %p %llu~%zd dropping cap refs on %s ret %d\n",
+	dout("page_mkwrite %p %llu~%zd dropping cap refs on %s ret %x\n",
 	     inode, off, len, ceph_cap_string(got), ret);
 	     inode, off, len, ceph_cap_string(got), ret);
 	ceph_put_cap_refs(ci, got);
 	ceph_put_cap_refs(ci, got);
 out_free:
 out_free:
 	ceph_restore_sigs(&oldset);
 	ceph_restore_sigs(&oldset);
 	ceph_free_cap_flush(prealloc_cf);
 	ceph_free_cap_flush(prealloc_cf);
-	if (ret < 0)
-		ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS;
+	if (err < 0)
+		ret = vmf_error(err);
 	return ret;
 	return ret;
 }
 }