Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d14c5d2 authored by Yehuda Sadeh's avatar Yehuda Sadeh Committed by Sage Weil
Browse files

ceph: factor out libceph from Ceph file system



This factors out protocol and low-level storage parts of ceph into a
separate libceph module living in net/ceph and include/linux/ceph.  This
is mostly a matter of moving files around.  However, a few key pieces
of the interface change as well:

 - ceph_client becomes ceph_fs_client and ceph_client, where the latter
   captures the mon and osd clients, and the fs_client gets the mds client
   and file system specific pieces.
 - Mount option parsing and debugfs setup is correspondingly broken into
   two pieces.
 - The mon client gets a generic handler callback for otherwise unknown
   messages (mds map, in this case).
 - The basic supported/required feature bits can be expanded (and are by
   ceph_fs_client).

No functional change, aside from some subtle error handling cases that got
cleaned up in the refactoring process.

Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent ae1533b6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1527,6 +1527,8 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client.git
S:	Supported
F:	Documentation/filesystems/ceph.txt
F:	fs/ceph
F:	net/ceph
F:	include/linux/ceph

CERTIFIED WIRELESS USB (WUSB) SUBSYSTEM:
M:	David Vrabel <david.vrabel@csr.com>
+2 −12
Original line number Diff line number Diff line
config CEPH_FS
        tristate "Ceph distributed file system (EXPERIMENTAL)"
	depends on INET && EXPERIMENTAL
	select CEPH_LIB
	select LIBCRC32C
	select CRYPTO_AES
	select CRYPTO
	default n
	help
	  Choose Y or M here to include support for mounting the
	  experimental Ceph distributed file system.  Ceph is an extremely
@@ -14,15 +16,3 @@ config CEPH_FS

	  If unsure, say N.
config CEPH_FS_PRETTYDEBUG
	bool "Include file:line in ceph debug output"
	depends on CEPH_FS
	default n
	help
	  If you say Y here, debug output will include a filename and
	  line to aid debugging.  This icnreases kernel size and slows
	  execution slightly when debug call sites are enabled (e.g.,
	  via CONFIG_DYNAMIC_DEBUG).

	  If unsure, say N.
+2 −9
Original line number Diff line number Diff line
@@ -8,15 +8,8 @@ obj-$(CONFIG_CEPH_FS) += ceph.o

ceph-objs := super.o inode.o dir.o file.o locks.o addr.o ioctl.o \
	export.o caps.o snap.o xattr.o \
	messenger.o msgpool.o buffer.o pagelist.o \
	mds_client.o mdsmap.o \
	mon_client.o \
	osd_client.o osdmap.o crush/crush.o crush/mapper.o crush/hash.o \
	debugfs.o \
	auth.o auth_none.o \
	crypto.o armor.o \
	auth_x.o \
	ceph_fs.o ceph_strings.o ceph_hash.o ceph_frag.o
	mds_client.o mdsmap.o strings.o ceph_frag.o \
	debugfs.o

else
#Otherwise we were called directly from the command

fs/ceph/README

deleted100644 → 0
+0 −20
Original line number Diff line number Diff line
#
# The following files are shared by (and manually synchronized
# between) the Ceph userland and kernel client.
#
# userland                  kernel
src/include/ceph_fs.h	    fs/ceph/ceph_fs.h
src/include/ceph_fs.cc	    fs/ceph/ceph_fs.c
src/include/msgr.h	    fs/ceph/msgr.h
src/include/rados.h	    fs/ceph/rados.h
src/include/ceph_strings.cc fs/ceph/ceph_strings.c
src/include/ceph_frag.h	    fs/ceph/ceph_frag.h
src/include/ceph_frag.cc    fs/ceph/ceph_frag.c
src/include/ceph_hash.h	    fs/ceph/ceph_hash.h
src/include/ceph_hash.cc    fs/ceph/ceph_hash.c
src/crush/crush.c	    fs/ceph/crush/crush.c
src/crush/crush.h	    fs/ceph/crush/crush.h
src/crush/mapper.c	    fs/ceph/crush/mapper.c
src/crush/mapper.h	    fs/ceph/crush/mapper.h
src/crush/hash.h	    fs/ceph/crush/hash.h
src/crush/hash.c	    fs/ceph/crush/hash.c
+34 −31
Original line number Diff line number Diff line
#include "ceph_debug.h"
#include <linux/ceph/ceph_debug.h>

#include <linux/backing-dev.h>
#include <linux/fs.h>
@@ -10,7 +10,8 @@
#include <linux/task_io_accounting_ops.h>

#include "super.h"
#include "osd_client.h"
#include "mds_client.h"
#include <linux/ceph/osd_client.h>

/*
 * Ceph address space ops.
@@ -193,7 +194,8 @@ static int readpage_nounlock(struct file *filp, struct page *page)
{
	struct inode *inode = filp->f_dentry->d_inode;
	struct ceph_inode_info *ci = ceph_inode(inode);
	struct ceph_osd_client *osdc = &ceph_inode_to_client(inode)->osdc;
	struct ceph_osd_client *osdc = 
		&ceph_inode_to_client(inode)->client->osdc;
	int err = 0;
	u64 len = PAGE_CACHE_SIZE;

@@ -265,7 +267,8 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
{
	struct inode *inode = file->f_dentry->d_inode;
	struct ceph_inode_info *ci = ceph_inode(inode);
	struct ceph_osd_client *osdc = &ceph_inode_to_client(inode)->osdc;
	struct ceph_osd_client *osdc =
		&ceph_inode_to_client(inode)->client->osdc;
	int rc = 0;
	struct page **pages;
	loff_t offset;
@@ -365,7 +368,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
{
	struct inode *inode;
	struct ceph_inode_info *ci;
	struct ceph_client *client;
	struct ceph_fs_client *fsc;
	struct ceph_osd_client *osdc;
	loff_t page_off = page->index << PAGE_CACHE_SHIFT;
	int len = PAGE_CACHE_SIZE;
@@ -383,8 +386,8 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
	}
	inode = page->mapping->host;
	ci = ceph_inode(inode);
	client = ceph_inode_to_client(inode);
	osdc = &client->osdc;
	fsc = ceph_inode_to_client(inode);
	osdc = &fsc->client->osdc;

	/* verify this is a writeable snap context */
	snapc = (void *)page->private;
@@ -414,10 +417,10 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
	dout("writepage %p page %p index %lu on %llu~%u snapc %p\n",
	     inode, page, page->index, page_off, len, snapc);

	writeback_stat = atomic_long_inc_return(&client->writeback_count);
	writeback_stat = atomic_long_inc_return(&fsc->writeback_count);
	if (writeback_stat >
	    CONGESTION_ON_THRESH(client->mount_args->congestion_kb))
		set_bdi_congested(&client->backing_dev_info, BLK_RW_ASYNC);
	    CONGESTION_ON_THRESH(fsc->mount_options->congestion_kb))
		set_bdi_congested(&fsc->backing_dev_info, BLK_RW_ASYNC);

	set_page_writeback(page);
	err = ceph_osdc_writepages(osdc, ceph_vino(inode),
@@ -496,7 +499,7 @@ static void writepages_finish(struct ceph_osd_request *req,
	struct address_space *mapping = inode->i_mapping;
	__s32 rc = -EIO;
	u64 bytes = 0;
	struct ceph_client *client = ceph_inode_to_client(inode);
	struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
	long writeback_stat;
	unsigned issued = ceph_caps_issued(ci);

@@ -529,10 +532,10 @@ static void writepages_finish(struct ceph_osd_request *req,
		WARN_ON(!PageUptodate(page));

		writeback_stat =
			atomic_long_dec_return(&client->writeback_count);
			atomic_long_dec_return(&fsc->writeback_count);
		if (writeback_stat <
		    CONGESTION_OFF_THRESH(client->mount_args->congestion_kb))
			clear_bdi_congested(&client->backing_dev_info,
		    CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
			clear_bdi_congested(&fsc->backing_dev_info,
					    BLK_RW_ASYNC);

		ceph_put_snap_context((void *)page->private);
@@ -569,13 +572,13 @@ static void writepages_finish(struct ceph_osd_request *req,
 * mempool.  we avoid the mempool if we can because req->r_num_pages
 * may be less than the maximum write size.
 */
static void alloc_page_vec(struct ceph_client *client,
static void alloc_page_vec(struct ceph_fs_client *fsc,
			   struct ceph_osd_request *req)
{
	req->r_pages = kmalloc(sizeof(struct page *) * req->r_num_pages,
			       GFP_NOFS);
	if (!req->r_pages) {
		req->r_pages = mempool_alloc(client->wb_pagevec_pool, GFP_NOFS);
		req->r_pages = mempool_alloc(fsc->wb_pagevec_pool, GFP_NOFS);
		req->r_pages_from_pool = 1;
		WARN_ON(!req->r_pages);
	}
@@ -590,7 +593,7 @@ static int ceph_writepages_start(struct address_space *mapping,
	struct inode *inode = mapping->host;
	struct backing_dev_info *bdi = mapping->backing_dev_info;
	struct ceph_inode_info *ci = ceph_inode(inode);
	struct ceph_client *client;
	struct ceph_fs_client *fsc;
	pgoff_t index, start, end;
	int range_whole = 0;
	int should_loop = 1;
@@ -617,13 +620,13 @@ static int ceph_writepages_start(struct address_space *mapping,
	     wbc->sync_mode == WB_SYNC_NONE ? "NONE" :
	     (wbc->sync_mode == WB_SYNC_ALL ? "ALL" : "HOLD"));

	client = ceph_inode_to_client(inode);
	if (client->mount_state == CEPH_MOUNT_SHUTDOWN) {
	fsc = ceph_inode_to_client(inode);
	if (fsc->mount_state == CEPH_MOUNT_SHUTDOWN) {
		pr_warning("writepage_start %p on forced umount\n", inode);
		return -EIO; /* we're in a forced umount, don't write! */
	}
	if (client->mount_args->wsize && client->mount_args->wsize < wsize)
		wsize = client->mount_args->wsize;
	if (fsc->mount_options->wsize && fsc->mount_options->wsize < wsize)
		wsize = fsc->mount_options->wsize;
	if (wsize < PAGE_CACHE_SIZE)
		wsize = PAGE_CACHE_SIZE;
	max_pages_ever = wsize >> PAGE_CACHE_SHIFT;
@@ -769,7 +772,7 @@ static int ceph_writepages_start(struct address_space *mapping,
				offset = (unsigned long long)page->index
					<< PAGE_CACHE_SHIFT;
				len = wsize;
				req = ceph_osdc_new_request(&client->osdc,
				req = ceph_osdc_new_request(&fsc->client->osdc,
					    &ci->i_layout,
					    ceph_vino(inode),
					    offset, &len,
@@ -782,7 +785,7 @@ static int ceph_writepages_start(struct address_space *mapping,
					    &inode->i_mtime, true, 1);
				max_pages = req->r_num_pages;

				alloc_page_vec(client, req);
				alloc_page_vec(fsc, req);
				req->r_callback = writepages_finish;
				req->r_inode = inode;
			}
@@ -794,10 +797,10 @@ static int ceph_writepages_start(struct address_space *mapping,
			     inode, page, page->index);

			writeback_stat =
			       atomic_long_inc_return(&client->writeback_count);
			       atomic_long_inc_return(&fsc->writeback_count);
			if (writeback_stat > CONGESTION_ON_THRESH(
				    client->mount_args->congestion_kb)) {
				set_bdi_congested(&client->backing_dev_info,
				    fsc->mount_options->congestion_kb)) {
				set_bdi_congested(&fsc->backing_dev_info,
						  BLK_RW_ASYNC);
			}

@@ -846,7 +849,7 @@ static int ceph_writepages_start(struct address_space *mapping,
		op->payload_len = cpu_to_le32(len);
		req->r_request->hdr.data_len = cpu_to_le32(len);

		ceph_osdc_start_request(&client->osdc, req, true);
		ceph_osdc_start_request(&fsc->client->osdc, req, true);
		req = NULL;

		/* continue? */
@@ -915,7 +918,7 @@ static int ceph_update_writeable_page(struct file *file,
{
	struct inode *inode = file->f_dentry->d_inode;
	struct ceph_inode_info *ci = ceph_inode(inode);
	struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc;
	struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
	loff_t page_off = pos & PAGE_CACHE_MASK;
	int pos_in_page = pos & ~PAGE_CACHE_MASK;
	int end_in_page = pos_in_page + len;
@@ -1053,8 +1056,8 @@ static int ceph_write_end(struct file *file, struct address_space *mapping,
			  struct page *page, void *fsdata)
{
	struct inode *inode = file->f_dentry->d_inode;
	struct ceph_client *client = ceph_inode_to_client(inode);
	struct ceph_mds_client *mdsc = &client->mdsc;
	struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
	struct ceph_mds_client *mdsc = fsc->mdsc;
	unsigned from = pos & (PAGE_CACHE_SIZE - 1);
	int check_cap = 0;

@@ -1123,7 +1126,7 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
{
	struct inode *inode = vma->vm_file->f_dentry->d_inode;
	struct page *page = vmf->page;
	struct ceph_mds_client *mdsc = &ceph_inode_to_client(inode)->mdsc;
	struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
	loff_t off = page->index << PAGE_CACHE_SHIFT;
	loff_t size, len;
	int ret;
Loading