mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 15:12:13 +02:00
fscache/cachefiles fixes
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEqG5UsNXhtOCrfGQP+7dXa6fLC2sFAmMPhkAACgkQ+7dXa6fL C2u6pg//erdjg+DhN1TxV0+ZCHGfeiV0NCLJVDHgYuAhWZGEWbq3x58bJU3nrUkE JFg0/En3Any3prxQ13FzCDEYGoA9bdgrE03d1EWPXH1Q7dK0dfCk8FoHSEBuIlk2 3M0sx0pY/TpeY8IeppXT2UI89wwVc+xCVOZtRDbjit0FU0QaAOSghgFtTrujLBpP ohIj83h41WzqSwB+WsyW170Sa0IWTizP+piziaxIIlt4JmCx0glwSU+JWiLj2s11 PgnkYjxmSvsYjPsYuxZOwU6vnefrfcOcy/ftYG701FUWdXbpqRMYlr9WhvwvFTUR WE3+XXx7sGiUrN9Cu67rhWNu7d1CshoJTmT8H6vPHd/w+vmOHWn84ReMaX3wowLp e+ePEglbYFEEeF2yJX3lvVV2vVr6hiUZ2NsOKoGFrPc8ynR2ec+sjMPkMDFSsHBX LI4jTIvzkiBpItcOt1gZei27BhwlFNX9Kj47/3lDPM5y6y5GTOEFoC/t79An9Zdj sc8ArAfaik618NO9V8Mw8PW4aNGHHnmD179q+Go+6eime0M6BA2ie70mcw+2ruMn PvlDRKR+IiwqGEuvOrm25Erswy2gslXVBvHtqCM8XmfLS6dGtAC2Qd4C8D7PwwT+ /LU0sCPlLg68juWDGDKF2Fh/Dvi0dnxUQdntS/d6+h7Iot/a42s= =z6wT -----END PGP SIGNATURE----- Merge tag 'fscache-fixes-20220831' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs Pull fscache/cachefiles fixes from David Howells: - Fix kdoc on fscache_use/unuse_cookie(). - Fix the error returned by cachefiles_ondemand_copen() from an upcall result. - Fix the distribution of requests in on-demand mode in cachefiles to be fairer by cycling through them rather than picking the one with the lowest ID each time (IDs being reused). * tag 'fscache-fixes-20220831' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: cachefiles: make on-demand request distribution fairer cachefiles: fix error return code in cachefiles_ondemand_copen() fscache: fix misdocumented parameter
This commit is contained in:
commit
c5e4d5e991
|
|
@ -111,6 +111,7 @@ struct cachefiles_cache {
|
|||
char *tag; /* cache binding tag */
|
||||
refcount_t unbind_pincount;/* refcount to do daemon unbind */
|
||||
struct xarray reqs; /* xarray of pending on-demand requests */
|
||||
unsigned long req_id_next;
|
||||
struct xarray ondemand_ids; /* xarray for ondemand_id allocation */
|
||||
u32 ondemand_id_next;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -158,9 +158,13 @@ int cachefiles_ondemand_copen(struct cachefiles_cache *cache, char *args)
|
|||
|
||||
/* fail OPEN request if daemon reports an error */
|
||||
if (size < 0) {
|
||||
if (!IS_ERR_VALUE(size))
|
||||
size = -EINVAL;
|
||||
req->error = size;
|
||||
if (!IS_ERR_VALUE(size)) {
|
||||
req->error = -EINVAL;
|
||||
ret = -EINVAL;
|
||||
} else {
|
||||
req->error = size;
|
||||
ret = 0;
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -238,14 +242,19 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
|
|||
unsigned long id = 0;
|
||||
size_t n;
|
||||
int ret = 0;
|
||||
XA_STATE(xas, &cache->reqs, 0);
|
||||
XA_STATE(xas, &cache->reqs, cache->req_id_next);
|
||||
|
||||
/*
|
||||
* Search for a request that has not ever been processed, to prevent
|
||||
* requests from being processed repeatedly.
|
||||
* Cyclically search for a request that has not ever been processed,
|
||||
* to prevent requests from being processed repeatedly, and make
|
||||
* request distribution fair.
|
||||
*/
|
||||
xa_lock(&cache->reqs);
|
||||
req = xas_find_marked(&xas, UINT_MAX, CACHEFILES_REQ_NEW);
|
||||
if (!req && cache->req_id_next > 0) {
|
||||
xas_set(&xas, 0);
|
||||
req = xas_find_marked(&xas, cache->req_id_next - 1, CACHEFILES_REQ_NEW);
|
||||
}
|
||||
if (!req) {
|
||||
xa_unlock(&cache->reqs);
|
||||
return 0;
|
||||
|
|
@ -260,6 +269,7 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache,
|
|||
}
|
||||
|
||||
xas_clear_mark(&xas, CACHEFILES_REQ_NEW);
|
||||
cache->req_id_next = xas.xa_index + 1;
|
||||
xa_unlock(&cache->reqs);
|
||||
|
||||
id = xas.xa_index;
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ struct fscache_cookie *fscache_acquire_cookie(struct fscache_volume *volume,
|
|||
|
||||
/**
|
||||
* fscache_use_cookie - Request usage of cookie attached to an object
|
||||
* @object: Object description
|
||||
* @cookie: The cookie representing the cache object
|
||||
* @will_modify: If cache is expected to be modified locally
|
||||
*
|
||||
* Request usage of the cookie attached to an object. The caller should tell
|
||||
|
|
@ -274,7 +274,7 @@ static inline void fscache_use_cookie(struct fscache_cookie *cookie,
|
|||
|
||||
/**
|
||||
* fscache_unuse_cookie - Cease usage of cookie attached to an object
|
||||
* @object: Object description
|
||||
* @cookie: The cookie representing the cache object
|
||||
* @aux_data: Updated auxiliary data (or NULL)
|
||||
* @object_size: Revised size of the object (or NULL)
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user