Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/sage/ceph-client

Pull ceph updates from Sage Weil:
 "This includes both the first pile of Ceph patches (which I sent to
  torvalds@vger, sigh) and a few new patches that add support for
  fscache for Ceph.  That includes a few fscache core fixes that David
  Howells asked go through the Ceph tree.  (Thanks go to Milosz Tanski
  for putting this feature together)

  This first batch of patches (included here) had (has) several
  important RBD bug fixes, hole punch support, several different
  cleanups in the page cache interactions, improvements in the truncate
  code (new truncate mutex to avoid shenanigans with i_mutex), and a
  series of fixes in the synchronous striping read/write code.

  On top of that is a random collection of small fixes all across the
  tree (error code checks and error path cleanup, obsolete wq flags,
  etc)"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client: (43 commits)
  ceph: use d_invalidate() to invalidate aliases
  ceph: remove ceph_lookup_inode()
  ceph: trivial buildbot warnings fix
  ceph: Do not do invalidate if the filesystem is mounted nofsc
  ceph: page still marked private_2
  ceph: ceph_readpage_to_fscache didn't check if marked
  ceph: clean PgPrivate2 on returning from readpages
  ceph: use fscache as a local presisent cache
  fscache: Netfs function for cleanup post readpages
  FS-Cache: Fix heading in documentation
  CacheFiles: Implement interface to check cache consistency
  FS-Cache: Add interface to check consistency of a cached object
  rbd: fix null dereference in dout
  rbd: fix buffer size for writes to images with snapshots
  libceph: use pg_num_mask instead of pgp_num_mask for pg.seed calc
  rbd: fix I/O error propagation for reads
  ceph: use vfs __set_page_dirty_nobuffers interface instead of doing it inside filesystem
  ceph: allow sync_read/write return partial successed size of read/write.
  ceph: fix bugs about handling short-read for sync read mode.
  ceph: remove useless variable revoked_rdcache
  ...
  • Loading branch information
Linus Torvalds committed Sep 9, 2013
2 parents 255ae3f + a8d436f commit 6cccc7d
Show file tree
Hide file tree
Showing 27 changed files with 1,396 additions and 189 deletions.
9 changes: 9 additions & 0 deletions Documentation/filesystems/caching/backend-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ performed on the denizens of the cache. These are held in a structure of type:
enough space in the cache to permit this.


(*) Check coherency state of an object [mandatory]:

int (*check_consistency)(struct fscache_object *object)

This method is called to have the cache check the saved auxiliary data of
the object against the netfs's idea of the state. 0 should be returned
if they're consistent and -ESTALE otherwise. -ENOMEM and -ERESTARTSYS
may also be returned.

(*) Update object [mandatory]:

int (*update_object)(struct fscache_object *object)
Expand Down
37 changes: 31 additions & 6 deletions Documentation/filesystems/caching/netfs-api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This document contains the following sections:
(9) Setting the data file size
(10) Page alloc/read/write
(11) Page uncaching
(12) Index and data file update
(12) Index and data file consistency
(13) Miscellaneous cookie operations
(14) Cookie unregistration
(15) Index invalidation
Expand Down Expand Up @@ -433,7 +433,7 @@ to the caller. The attribute adjustment excludes read and write operations.


=====================
PAGE READ/ALLOC/WRITE
PAGE ALLOC/READ/WRITE
=====================

And the sixth step is to store and retrieve pages in the cache. There are
Expand Down Expand Up @@ -499,7 +499,7 @@ Else if there's a copy of the page resident in the cache:
(*) An argument that's 0 on success or negative for an error code.

If an error occurs, it should be assumed that the page contains no usable
data.
data. fscache_readpages_cancel() may need to be called.

end_io_func() will be called in process context if the read is results in
an error, but it might be called in interrupt context if the read is
Expand Down Expand Up @@ -623,6 +623,22 @@ some of the pages being read and some being allocated. Those pages will have
been marked appropriately and will need uncaching.


CANCELLATION OF UNREAD PAGES
----------------------------

If one or more pages are passed to fscache_read_or_alloc_pages() but not then
read from the cache and also not read from the underlying filesystem then
those pages will need to have any marks and reservations removed. This can be
done by calling:

void fscache_readpages_cancel(struct fscache_cookie *cookie,
struct list_head *pages);

prior to returning to the caller. The cookie argument should be as passed to
fscache_read_or_alloc_pages(). Every page in the pages list will be examined
and any that have PG_fscache set will be uncached.


==============
PAGE UNCACHING
==============
Expand Down Expand Up @@ -690,9 +706,18 @@ written to the cache and for the cache to finish with the page generally. No
error is returned.


==========================
INDEX AND DATA FILE UPDATE
==========================
===============================
INDEX AND DATA FILE CONSISTENCY
===============================

To find out whether auxiliary data for an object is up to data within the
cache, the following function can be called:

int fscache_check_consistency(struct fscache_cookie *cookie)

This will call back to the netfs to check whether the auxiliary data associated
with a cookie is correct. It returns 0 if it is and -ESTALE if it isn't; it
may also return -ENOMEM and -ERESTARTSYS.

To request an update of the index data for an index or other object, the
following function should be called:
Expand Down
36 changes: 19 additions & 17 deletions drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1561,11 +1561,12 @@ rbd_img_obj_request_read_callback(struct rbd_obj_request *obj_request)
obj_request, obj_request->img_request, obj_request->result,
xferred, length);
/*
* ENOENT means a hole in the image. We zero-fill the
* entire length of the request. A short read also implies
* zero-fill to the end of the request. Either way we
* update the xferred count to indicate the whole request
* was satisfied.
* ENOENT means a hole in the image. We zero-fill the entire
* length of the request. A short read also implies zero-fill
* to the end of the request. An error requires the whole
* length of the request to be reported finished with an error
* to the block layer. In each case we update the xferred
* count to indicate the whole request was satisfied.
*/
rbd_assert(obj_request->type != OBJ_REQUEST_NODATA);
if (obj_request->result == -ENOENT) {
Expand All @@ -1574,14 +1575,13 @@ rbd_img_obj_request_read_callback(struct rbd_obj_request *obj_request)
else
zero_pages(obj_request->pages, 0, length);
obj_request->result = 0;
obj_request->xferred = length;
} else if (xferred < length && !obj_request->result) {
if (obj_request->type == OBJ_REQUEST_BIO)
zero_bio_chain(obj_request->bio_list, xferred);
else
zero_pages(obj_request->pages, xferred, length);
obj_request->xferred = length;
}
obj_request->xferred = length;
obj_request_done_set(obj_request);
}

Expand Down Expand Up @@ -2167,9 +2167,9 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
struct rbd_obj_request *obj_request = NULL;
struct rbd_obj_request *next_obj_request;
bool write_request = img_request_write_test(img_request);
struct bio *bio_list = 0;
struct bio *bio_list = NULL;
unsigned int bio_offset = 0;
struct page **pages = 0;
struct page **pages = NULL;
u64 img_offset;
u64 resid;
u16 opcode;
Expand Down Expand Up @@ -2207,6 +2207,11 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
rbd_segment_name_free(object_name);
if (!obj_request)
goto out_unwind;
/*
* set obj_request->img_request before creating the
* osd_request so that it gets the right snapc
*/
rbd_img_obj_request_add(img_request, obj_request);

if (type == OBJ_REQUEST_BIO) {
unsigned int clone_size;
Expand Down Expand Up @@ -2248,11 +2253,6 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
obj_request->pages, length,
offset & ~PAGE_MASK, false, false);

/*
* set obj_request->img_request before formatting
* the osd_request so that it gets the right snapc
*/
rbd_img_obj_request_add(img_request, obj_request);
if (write_request)
rbd_osd_req_format_write(obj_request);
else
Expand Down Expand Up @@ -3706,12 +3706,14 @@ static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id,
if (ret < sizeof (size_buf))
return -ERANGE;

if (order)
if (order) {
*order = size_buf.order;
dout(" order %u", (unsigned int)*order);
}
*snap_size = le64_to_cpu(size_buf.size);

dout(" snap_id 0x%016llx order = %u, snap_size = %llu\n",
(unsigned long long)snap_id, (unsigned int)*order,
dout(" snap_id 0x%016llx snap_size = %llu\n",
(unsigned long long)snap_id,
(unsigned long long)*snap_size);

return 0;
Expand Down
26 changes: 26 additions & 0 deletions fs/cachefiles/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,31 @@ static void cachefiles_sync_cache(struct fscache_cache *_cache)
ret);
}

/*
* check if the backing cache is updated to FS-Cache
* - called by FS-Cache when evaluates if need to invalidate the cache
*/
static bool cachefiles_check_consistency(struct fscache_operation *op)
{
struct cachefiles_object *object;
struct cachefiles_cache *cache;
const struct cred *saved_cred;
int ret;

_enter("{OBJ%x}", op->object->debug_id);

object = container_of(op->object, struct cachefiles_object, fscache);
cache = container_of(object->fscache.cache,
struct cachefiles_cache, cache);

cachefiles_begin_secure(cache, &saved_cred);
ret = cachefiles_check_auxdata(object);
cachefiles_end_secure(cache, saved_cred);

_leave(" = %d", ret);
return ret;
}

/*
* notification the attributes on an object have changed
* - called with reads/writes excluded by FS-Cache
Expand Down Expand Up @@ -522,4 +547,5 @@ const struct fscache_cache_ops cachefiles_cache_ops = {
.write_page = cachefiles_write_page,
.uncache_page = cachefiles_uncache_page,
.dissociate_pages = cachefiles_dissociate_pages,
.check_consistency = cachefiles_check_consistency,
};
1 change: 1 addition & 0 deletions fs/cachefiles/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ extern int cachefiles_set_object_xattr(struct cachefiles_object *object,
struct cachefiles_xattr *auxdata);
extern int cachefiles_update_object_xattr(struct cachefiles_object *object,
struct cachefiles_xattr *auxdata);
extern int cachefiles_check_auxdata(struct cachefiles_object *object);
extern int cachefiles_check_object_xattr(struct cachefiles_object *object,
struct cachefiles_xattr *auxdata);
extern int cachefiles_remove_object_xattr(struct cachefiles_cache *cache,
Expand Down
36 changes: 36 additions & 0 deletions fs/cachefiles/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,42 @@ int cachefiles_update_object_xattr(struct cachefiles_object *object,
return ret;
}

/*
* check the consistency between the backing cache and the FS-Cache cookie
*/
int cachefiles_check_auxdata(struct cachefiles_object *object)
{
struct cachefiles_xattr *auxbuf;
struct dentry *dentry = object->dentry;
unsigned int dlen;
int ret;

ASSERT(dentry);
ASSERT(dentry->d_inode);
ASSERT(object->fscache.cookie->def->check_aux);

auxbuf = kmalloc(sizeof(struct cachefiles_xattr) + 512, GFP_KERNEL);
if (!auxbuf)
return -ENOMEM;

auxbuf->len = vfs_getxattr(dentry, cachefiles_xattr_cache,
&auxbuf->type, 512 + 1);
if (auxbuf->len < 1)
return -ESTALE;

if (auxbuf->type != object->fscache.cookie->def->type)
return -ESTALE;

dlen = auxbuf->len - 1;
ret = fscache_check_aux(&object->fscache, &auxbuf->data, dlen);

kfree(auxbuf);
if (ret != FSCACHE_CHECKAUX_OKAY)
return -ESTALE;

return 0;
}

/*
* check the state xattr on a cache file
* - return -ESTALE if the object should be deleted
Expand Down
9 changes: 9 additions & 0 deletions fs/ceph/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ config CEPH_FS

If unsure, say N.

if CEPH_FS
config CEPH_FSCACHE
bool "Enable Ceph client caching support"
depends on CEPH_FS=m && FSCACHE || CEPH_FS=y && FSCACHE=y
help
Choose Y here to enable persistent, read-only local
caching support for Ceph clients using FS-Cache

endif
1 change: 1 addition & 0 deletions fs/ceph/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ ceph-y := super.o inode.o dir.o file.o locks.o addr.o ioctl.o \
mds_client.o mdsmap.o strings.o ceph_frag.o \
debugfs.o

ceph-$(CONFIG_CEPH_FSCACHE) += cache.o
Loading

0 comments on commit 6cccc7d

Please sign in to comment.