#include <uapi/linux/lustre/lustre_ioctl.h>
#include <lustre_net.h>
#include <lustre_obdo.h>
-#include <uapi/linux/lustre/lustre_param.h>
#include <obd.h>
#include <obd_cksum.h>
#include <obd_class.h>
/* Do not ask for more than OBD_MAX_GRANT - a margin for server
* to add extent tax, etc.
*/
- oa->o_undirty = min(undirty, OBD_MAX_GRANT -
- (PTLRPC_MAX_BRW_PAGES << PAGE_SHIFT)*4UL);
+ oa->o_undirty = min(undirty, OBD_MAX_GRANT &
+ ~(PTLRPC_MAX_BRW_SIZE * 4UL));
}
oa->o_grant = cli->cl_avail_grant + cli->cl_reserved_grant;
oa->o_dropped = cli->cl_lost_grant;
mutex_lock(&client_gtd.gtd_mutex);
list_for_each_entry(cli, &client_gtd.gtd_clients,
cl_grant_chain) {
- if (++rpc_sent < GRANT_SHRINK_RPC_BATCH &&
- osc_should_shrink_grant(cli))
+ if (rpc_sent < GRANT_SHRINK_RPC_BATCH &&
+ osc_should_shrink_grant(cli)) {
osc_shrink_grant(cli);
+ rpc_sent++;
+ }
if (!init_next_shrink) {
if (cli->cl_next_shrink_grant < next_shrink &&
if (client_gtd.gtd_stopped == 1)
return;
- if (next_shrink > ktime_get_seconds())
- schedule_delayed_work(&work, msecs_to_jiffies(
- (next_shrink - ktime_get_seconds()) *
- MSEC_PER_SEC));
- else
+ if (next_shrink > ktime_get_seconds()) {
+ time64_t delay = next_shrink - ktime_get_seconds();
+
+ schedule_delayed_work(&work, cfs_time_seconds(delay));
+ } else {
schedule_work(&work.work);
+ }
+}
+
+void osc_schedule_grant_work(void)
+{
+ cancel_delayed_work_sync(&work);
+ schedule_work(&work.work);
}
/**
/* return error if any niobuf was in error */
for (i = 0; i < niocount; i++) {
- if ((int)remote_rcs[i] < 0)
- return(remote_rcs[i]);
+ if ((int)remote_rcs[i] < 0) {
+ CDEBUG(D_INFO, "rc[%d]: %d req %p\n",
+ i, remote_rcs[i], req);
+ return remote_rcs[i];
+ }
if (remote_rcs[i] != 0) {
CDEBUG(D_INFO, "rc[%d] invalid (%d) req %p\n",
kunmap(pga[i]->pg);
}
- rc = ll_vfs_fsync_range(filp, 0, LLONG_MAX, 1);
+ rc = vfs_fsync_range(filp, 0, LLONG_MAX, 1);
if (rc)
CERROR("%s: sync returns %d\n", dbgcksum_file_name, rc);
filp_close(filp, NULL);
CDEBUG(D_QUOTA, "setdq for [%u %u %u] with valid %#llx, flags %x\n",
body->oa.o_uid, body->oa.o_gid, body->oa.o_projid,
body->oa.o_valid, body->oa.o_flags);
- osc_quota_setdq(cli, qid, body->oa.o_valid,
+ osc_quota_setdq(cli, req->rq_xid, qid, body->oa.o_valid,
body->oa.o_flags);
}
int rc;
ENTRY;
+ if (obd->obd_osfs_age >= max_age) {
+ CDEBUG(D_SUPER,
+ "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n",
+ obd->obd_name, &obd->obd_osfs,
+ obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
+ obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
+ spin_lock(&obd->obd_osfs_lock);
+ memcpy(oinfo->oi_osfs, &obd->obd_osfs, sizeof(*oinfo->oi_osfs));
+ spin_unlock(&obd->obd_osfs_lock);
+ oinfo->oi_flags |= OBD_STATFS_FROM_CACHE;
+ if (oinfo->oi_cb_up)
+ oinfo->oi_cb_up(oinfo, 0);
+
+ RETURN(0);
+ }
+
/* We could possibly pass max_age in the request (as an absolute
* timestamp or a "seconds.usec ago") so the target can avoid doing
* extra calls into the filesystem if that isn't necessary (e.g.
static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
void *karg, void __user *uarg)
{
- struct obd_device *obd = exp->exp_obd;
- struct obd_ioctl_data *data = karg;
- int err = 0;
- ENTRY;
+ struct obd_device *obd = exp->exp_obd;
+ struct obd_ioctl_data *data = karg;
+ int rc = 0;
+ ENTRY;
if (!try_module_get(THIS_MODULE)) {
CERROR("%s: cannot get module '%s'\n", obd->obd_name,
module_name(THIS_MODULE));
return -EINVAL;
}
- switch (cmd) {
- case OBD_IOC_CLIENT_RECOVER:
- err = ptlrpc_recover_import(obd->u.cli.cl_import,
- data->ioc_inlbuf1, 0);
- if (err > 0)
- err = 0;
- GOTO(out, err);
- case IOC_OSC_SET_ACTIVE:
- err = ptlrpc_set_import_active(obd->u.cli.cl_import,
- data->ioc_offset);
- GOTO(out, err);
- case OBD_IOC_PING_TARGET:
- err = ptlrpc_obd_ping(obd);
- GOTO(out, err);
+ switch (cmd) {
+ case OBD_IOC_CLIENT_RECOVER:
+ rc = ptlrpc_recover_import(obd->u.cli.cl_import,
+ data->ioc_inlbuf1, 0);
+ if (rc > 0)
+ rc = 0;
+ break;
+ case IOC_OSC_SET_ACTIVE:
+ rc = ptlrpc_set_import_active(obd->u.cli.cl_import,
+ data->ioc_offset);
+ break;
default:
- CDEBUG(D_INODE, "unrecognised ioctl %#x by %s\n",
- cmd, current_comm());
- GOTO(out, err = -ENOTTY);
+ rc = -ENOTTY;
+ CDEBUG(D_INODE, "%s: unrecognised ioctl %#x by %s: rc = %d\n",
+ obd->obd_name, cmd, current_comm(), rc);
+ break;
}
-out:
+
module_put(THIS_MODULE);
- return err;
+ return rc;
}
int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
RETURN(0);
}
- if (KEY_IS(KEY_CACHE_SET)) {
- struct client_obd *cli = &obd->u.cli;
-
- LASSERT(cli->cl_cache == NULL); /* only once */
- cli->cl_cache = (struct cl_client_cache *)val;
- cl_cache_incref(cli->cl_cache);
- cli->cl_lru_left = &cli->cl_cache->ccc_lru_left;
-
- /* add this osc into entity list */
- LASSERT(list_empty(&cli->cl_lru_osc));
- spin_lock(&cli->cl_cache->ccc_lru_lock);
- list_add(&cli->cl_lru_osc, &cli->cl_cache->ccc_lru);
- spin_unlock(&cli->cl_cache->ccc_lru_lock);
-
- RETURN(0);
- }
-
if (KEY_IS(KEY_CACHE_LRU_SHRINK)) {
struct client_obd *cli = &obd->u.cli;
long nr = atomic_long_read(&cli->cl_lru_in_list) >> 1;
spin_lock(&cli->cl_loi_list_lock);
grant = cli->cl_avail_grant + cli->cl_reserved_grant;
- if (data->ocd_connect_flags & OBD_CONNECT_GRANT_PARAM)
+ if (data->ocd_connect_flags & OBD_CONNECT_GRANT_PARAM) {
+ /* restore ocd_grant_blkbits as client page bits */
+ data->ocd_grant_blkbits = PAGE_SHIFT;
grant += cli->cl_dirty_grant;
- else
+ } else {
grant += cli->cl_dirty_pages << PAGE_SHIFT;
+ }
data->ocd_grant = grant ? : 2 * cli_brw_size(obd);
lost_grant = cli->cl_lost_grant;
cli->cl_lost_grant = 0;
* Cancel all unused and granted extent lock.
*/
if (lock->l_resource->lr_type == LDLM_EXTENT &&
- lock->l_granted_mode == lock->l_req_mode &&
+ ldlm_is_granted(lock) &&
osc_ldlm_weigh_ast(lock) == 0)
RETURN(1);
}
EXPORT_SYMBOL(osc_cleanup_common);
-int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg)
-{
- ssize_t count = class_modify_config(lcfg, PARAM_OSC,
- &obd->obd_kset.kobj);
- return count > 0 ? 0 : count;
-}
-
-static int osc_process_config(struct obd_device *obd, size_t len, void *buf)
-{
- return osc_process_config_base(obd, buf);
-}
-
static struct obd_ops osc_obd_ops = {
.o_owner = THIS_MODULE,
.o_setup = osc_setup,
.o_cleanup = osc_cleanup_common,
.o_add_conn = client_import_add_conn,
.o_del_conn = client_import_del_conn,
- .o_connect = client_connect_import,
+ .o_connect = client_connect_import,
.o_reconnect = osc_reconnect,
.o_disconnect = osc_disconnect,
.o_statfs = osc_statfs,
.o_iocontrol = osc_iocontrol,
.o_set_info_async = osc_set_info_async,
.o_import_event = osc_import_event,
- .o_process_config = osc_process_config,
.o_quotactl = osc_quotactl,
};
static int __init osc_init(void)
{
- bool enable_proc = true;
- struct obd_type *type;
unsigned int reqpool_size;
unsigned int reqsize;
int rc;
if (rc)
RETURN(rc);
- type = class_search_type(LUSTRE_OSP_NAME);
- if (type != NULL && type->typ_procsym != NULL)
- enable_proc = false;
-
- rc = class_register_type(&osc_obd_ops, NULL, enable_proc, NULL,
+ rc = class_register_type(&osc_obd_ops, NULL, true, NULL,
LUSTRE_OSC_NAME, &osc_device_type);
if (rc)
GOTO(out_kmem, rc);