diff options
Diffstat (limited to 'kernel/drivers/staging/lustre/lustre/osc')
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/Makefile | 3 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/lproc_osc.c | 454 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/osc_cache.c | 246 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/osc_cl_internal.h | 3 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/osc_dev.c | 26 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/osc_internal.h | 15 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/osc_io.c | 136 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/osc_lock.c | 155 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/osc_object.c | 24 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/osc_page.c | 49 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/osc_quota.c | 25 | ||||
-rw-r--r-- | kernel/drivers/staging/lustre/lustre/osc/osc_request.c | 463 |
12 files changed, 808 insertions, 791 deletions
diff --git a/kernel/drivers/staging/lustre/lustre/osc/Makefile b/kernel/drivers/staging/lustre/lustre/osc/Makefile index 54927fba4..37cdeea9a 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/Makefile +++ b/kernel/drivers/staging/lustre/lustre/osc/Makefile @@ -1,4 +1,3 @@ obj-$(CONFIG_LUSTRE_FS) += osc.o osc-y := osc_request.o osc_dev.o osc_object.o \ - osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o -osc-$(CONFIG_PROC_FS) += lproc_osc.o + osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o lproc_osc.o diff --git a/kernel/drivers/staging/lustre/lustre/osc/lproc_osc.c b/kernel/drivers/staging/lustre/lustre/osc/lproc_osc.c index 15a662098..c4d44e70f 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/kernel/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -42,84 +42,99 @@ #include <linux/seq_file.h> #include "osc_internal.h" -static int osc_active_seq_show(struct seq_file *m, void *v) +static ssize_t active_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; - - LPROCFS_CLIMP_CHECK(dev); - seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive); - LPROCFS_CLIMP_EXIT(dev); + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); - return 0; + return sprintf(buf, "%d\n", !dev->u.cli.cl_import->imp_deactive); } -static ssize_t osc_active_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t active_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - int val, rc; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; - if (val < 0 || val > 1) + if (val > 1) return -ERANGE; /* opposite senses */ if (dev->u.cli.cl_import->imp_deactive == val) rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val); else - CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n", val); + CDEBUG(D_CONFIG, "activate %ld: ignoring repeat request\n", + val); return count; } -LPROC_SEQ_FOPS(osc_active); +LUSTRE_RW_ATTR(active); -static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v) +static ssize_t max_rpcs_in_flight_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; - client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight); - client_obd_list_unlock(&cli->cl_loi_list_lock); - - return 0; + return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight); } -static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_rpcs_in_flight_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; - struct ptlrpc_request_pool *pool = cli->cl_import->imp_rq_pool; - int val, rc; + int rc; + unsigned long val; + int adding, added, req_count; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; if (val < 1 || val > OSC_MAX_RIF_MAX) return -ERANGE; - LPROCFS_CLIMP_CHECK(dev); - if (pool && val > cli->cl_max_rpcs_in_flight) - pool->prp_populate(pool, val-cli->cl_max_rpcs_in_flight); + adding = val - cli->cl_max_rpcs_in_flight; + req_count = atomic_read(&osc_pool_req_count); + if (adding > 0 && req_count < osc_reqpool_maxreqcount) { + /* + * There might be some race which will cause over-limit + * allocation, but it is fine. + */ + if (req_count + adding > osc_reqpool_maxreqcount) + adding = osc_reqpool_maxreqcount - req_count; + + added = osc_rq_pool->prp_populate(osc_rq_pool, adding); + atomic_add(added, &osc_pool_req_count); + } client_obd_list_lock(&cli->cl_loi_list_lock); cli->cl_max_rpcs_in_flight = val; client_obd_list_unlock(&cli->cl_loi_list_lock); - LPROCFS_CLIMP_EXIT(dev); return count; } -LPROC_SEQ_FOPS(osc_max_rpcs_in_flight); +LUSTRE_RW_ATTR(max_rpcs_in_flight); -static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v) +static ssize_t max_dirty_mb_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; long val; int mult; @@ -129,22 +144,26 @@ static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v) client_obd_list_unlock(&cli->cl_loi_list_lock); mult = 1 << 20; - return lprocfs_seq_read_frac_helper(m, val, mult); + return lprocfs_read_frac_helper(buf, PAGE_SIZE, val, mult); } -static ssize_t osc_max_dirty_mb_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_dirty_mb_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; - int pages_number, mult, rc; + int rc; + unsigned long pages_number; - mult = 1 << (20 - PAGE_CACHE_SHIFT); - rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); + rc = kstrtoul(buffer, 10, &pages_number); if (rc) return rc; + pages_number *= 1 << (20 - PAGE_CACHE_SHIFT); /* MB -> pages */ + if (pages_number <= 0 || pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) || pages_number > totalram_pages / 4) /* 1/4 of RAM */ @@ -157,7 +176,7 @@ static ssize_t osc_max_dirty_mb_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_max_dirty_mb); +LUSTRE_RW_ATTR(max_dirty_mb); static int osc_cached_mb_seq_show(struct seq_file *m, void *v) { @@ -208,46 +227,54 @@ static ssize_t osc_cached_mb_seq_write(struct file *file, return count; } + LPROC_SEQ_FOPS(osc_cached_mb); -static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v) +static ssize_t cur_dirty_bytes_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; + int len; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%lu\n", cli->cl_dirty); + len = sprintf(buf, "%lu\n", cli->cl_dirty); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes); +LUSTRE_RO_ATTR(cur_dirty_bytes); -static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v) +static ssize_t cur_grant_bytes_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; + int len; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%lu\n", cli->cl_avail_grant); + len = sprintf(buf, "%lu\n", cli->cl_avail_grant); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t cur_grant_bytes_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &obd->u.cli; - int rc; - __u64 val; - - if (obd == NULL) - return 0; + int rc; + unsigned long long val; - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtoull(buffer, 10, &val); if (rc) return rc; @@ -255,54 +282,56 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, client_obd_list_lock(&cli->cl_loi_list_lock); if (val >= cli->cl_avail_grant) { client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return -EINVAL; } client_obd_list_unlock(&cli->cl_loi_list_lock); - LPROCFS_CLIMP_CHECK(obd); if (cli->cl_import->imp_state == LUSTRE_IMP_FULL) rc = osc_shrink_grant_to_target(cli, val); - LPROCFS_CLIMP_EXIT(obd); if (rc) return rc; return count; } -LPROC_SEQ_FOPS(osc_cur_grant_bytes); +LUSTRE_RW_ATTR(cur_grant_bytes); -static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v) +static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *dev = m->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; + int len; client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(m, "%lu\n", cli->cl_lost_grant); + len = sprintf(buf, "%lu\n", cli->cl_lost_grant); client_obd_list_unlock(&cli->cl_loi_list_lock); - return 0; + return len; } -LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes); +LUSTRE_RO_ATTR(cur_lost_grant_bytes); -static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v) +static ssize_t grant_shrink_interval_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - if (obd == NULL) - return 0; - seq_printf(m, "%d\n", obd->u.cli.cl_grant_shrink_interval); - return 0; + return sprintf(buf, "%d\n", obd->u.cli.cl_grant_shrink_interval); } -static ssize_t osc_grant_shrink_interval_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t grant_shrink_interval_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int val, rc; - - if (obd == NULL) - return 0; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -313,30 +342,29 @@ static ssize_t osc_grant_shrink_interval_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_grant_shrink_interval); +LUSTRE_RW_ATTR(grant_shrink_interval); -static int osc_checksum_seq_show(struct seq_file *m, void *v) +static ssize_t checksums_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; - - if (obd == NULL) - return 0; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - seq_printf(m, "%d\n", obd->u.cli.cl_checksum ? 1 : 0); - return 0; + return sprintf(buf, "%d\n", obd->u.cli.cl_checksum ? 1 : 0); } -static ssize_t osc_checksum_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t checksums_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int val, rc; - - if (obd == NULL) - return 0; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; @@ -344,12 +372,13 @@ static ssize_t osc_checksum_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(osc_checksum); +LUSTRE_RW_ATTR(checksums); static int osc_checksum_type_seq_show(struct seq_file *m, void *v) { struct obd_device *obd = m->private; int i; + DECLARE_CKSUM_NAME; if (obd == NULL) @@ -373,6 +402,7 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, { struct obd_device *obd = ((struct seq_file *)file->private_data)->private; int i; + DECLARE_CKSUM_NAME; char kernbuf[10]; @@ -398,103 +428,125 @@ static ssize_t osc_checksum_type_seq_write(struct file *file, } return -EINVAL; } + LPROC_SEQ_FOPS(osc_checksum_type); -static int osc_resend_count_seq_show(struct seq_file *m, void *v) +static ssize_t resend_count_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends)); - return 0; + return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends)); } -static ssize_t osc_resend_count_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t resend_count_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - int val, rc; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); + int rc; + unsigned long val; - rc = lprocfs_write_helper(buffer, count, &val); + rc = kstrtoul(buffer, 10, &val); if (rc) return rc; - if (val < 0) - return -EINVAL; - atomic_set(&obd->u.cli.cl_resends, val); return count; } -LPROC_SEQ_FOPS(osc_resend_count); +LUSTRE_RW_ATTR(resend_count); -static int osc_contention_seconds_seq_show(struct seq_file *m, void *v) +static ssize_t contention_seconds_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); - seq_printf(m, "%u\n", od->od_contention_time); - return 0; + return sprintf(buf, "%u\n", od->od_contention_time); } -static ssize_t osc_contention_seconds_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t contention_seconds_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?: count; } -LPROC_SEQ_FOPS(osc_contention_seconds); +LUSTRE_RW_ATTR(contention_seconds); -static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v) +static ssize_t lockless_truncate_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); - seq_printf(m, "%u\n", od->od_lockless_truncate); - return 0; + return sprintf(buf, "%u\n", od->od_lockless_truncate); } -static ssize_t osc_lockless_truncate_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t lockless_truncate_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); struct osc_device *od = obd2osc_dev(obd); return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?: count; } -LPROC_SEQ_FOPS(osc_lockless_truncate); +LUSTRE_RW_ATTR(lockless_truncate); -static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v) +static ssize_t destroys_in_flight_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct obd_device *obd = m->private; + struct obd_device *obd = container_of(kobj, struct obd_device, + obd_kobj); - seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_destroy_in_flight)); - return 0; + return sprintf(buf, "%u\n", + atomic_read(&obd->u.cli.cl_destroy_in_flight)); } -LPROC_SEQ_FOPS_RO(osc_destroys_in_flight); +LUSTRE_RO_ATTR(destroys_in_flight); -static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v) +static ssize_t max_pages_per_rpc_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - return lprocfs_obd_rd_max_pages_per_rpc(m, m->private); + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); + struct client_obd *cli = &dev->u.cli; + + return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc); } -static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t max_pages_per_rpc_store(struct kobject *kobj, + struct attribute *attr, + const char *buffer, + size_t count) { - struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct obd_device *dev = container_of(kobj, struct obd_device, + obd_kobj); struct client_obd *cli = &dev->u.cli; struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data; int chunk_mask, rc; - __u64 val; + unsigned long long val; - rc = lprocfs_write_u64_helper(buffer, count, &val); + rc = kstrtoull(buffer, 10, &val); if (rc) return rc; @@ -502,32 +554,21 @@ static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file, if (val >= ONE_MB_BRW_SIZE) val >>= PAGE_CACHE_SHIFT; - LPROCFS_CLIMP_CHECK(dev); - chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_CACHE_SHIFT)) - 1); /* max_pages_per_rpc must be chunk aligned */ val = (val + ~chunk_mask) & chunk_mask; if (val == 0 || val > ocd->ocd_brw_size >> PAGE_CACHE_SHIFT) { - LPROCFS_CLIMP_EXIT(dev); return -ERANGE; } client_obd_list_lock(&cli->cl_loi_list_lock); cli->cl_max_pages_per_rpc = val; client_obd_list_unlock(&cli->cl_loi_list_lock); - LPROCFS_CLIMP_EXIT(dev); return count; } -LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc); +LUSTRE_RW_ATTR(max_pages_per_rpc); -LPROC_SEQ_FOPS_RO_TYPE(osc, uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags); -LPROC_SEQ_FOPS_RO_TYPE(osc, blksize); -LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal); -LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree); -LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail); -LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal); -LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree); LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid); LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts); @@ -539,62 +580,36 @@ LPROC_SEQ_FOPS_RW_TYPE(osc, import); LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov); static struct lprocfs_vars lprocfs_osc_obd_vars[] = { - { "uuid", &osc_uuid_fops, NULL, 0 }, { "ping", &osc_ping_fops, NULL, 0222 }, { "connect_flags", &osc_connect_flags_fops, NULL, 0 }, - { "blocksize", &osc_blksize_fops, NULL, 0 }, - { "kbytestotal", &osc_kbytestotal_fops, NULL, 0 }, - { "kbytesfree", &osc_kbytesfree_fops, NULL, 0 }, - { "kbytesavail", &osc_kbytesavail_fops, NULL, 0 }, - { "filestotal", &osc_filestotal_fops, NULL, 0 }, - { "filesfree", &osc_filesfree_fops, NULL, 0 }, /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ { "ost_server_uuid", &osc_server_uuid_fops, NULL, 0 }, { "ost_conn_uuid", &osc_conn_uuid_fops, NULL, 0 }, - { "active", &osc_active_fops, NULL }, - { "max_pages_per_rpc", &osc_obd_max_pages_per_rpc_fops, NULL }, - { "max_rpcs_in_flight", &osc_max_rpcs_in_flight_fops, NULL }, - { "destroys_in_flight", &osc_destroys_in_flight_fops, NULL, 0 }, - { "max_dirty_mb", &osc_max_dirty_mb_fops, NULL }, { "osc_cached_mb", &osc_cached_mb_fops, NULL }, - { "cur_dirty_bytes", &osc_cur_dirty_bytes_fops, NULL, 0 }, - { "cur_grant_bytes", &osc_cur_grant_bytes_fops, NULL }, - { "cur_lost_grant_bytes", &osc_cur_lost_grant_bytes_fops, NULL, 0}, - { "grant_shrink_interval", &osc_grant_shrink_interval_fops, NULL }, - { "checksums", &osc_checksum_fops, NULL }, { "checksum_type", &osc_checksum_type_fops, NULL }, - { "resend_count", &osc_resend_count_fops, NULL}, { "timeouts", &osc_timeouts_fops, NULL, 0 }, - { "contention_seconds", &osc_contention_seconds_fops, NULL }, - { "lockless_truncate", &osc_lockless_truncate_fops, NULL }, { "import", &osc_import_fops, NULL }, { "state", &osc_state_fops, NULL, 0 }, { "pinger_recov", &osc_pinger_recov_fops, NULL }, { NULL } }; -LPROC_SEQ_FOPS_RO_TYPE(osc, numrefs); -static struct lprocfs_vars lprocfs_osc_module_vars[] = { - { "num_refs", &osc_numrefs_fops, NULL, 0 }, - { NULL } -}; - #define pct(a, b) (b ? a * 100 / b : 0) static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) { - struct timeval now; + struct timespec64 now; struct obd_device *dev = seq->private; struct client_obd *cli = &dev->u.cli; unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum; int i; - do_gettimeofday(&now); + ktime_get_real_ts64(&now); client_obd_list_lock(&cli->cl_loi_list_lock); - seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, (unsigned long)now.tv_usec); + seq_printf(seq, "snapshot_time: %llu.%9lu (secs.usecs)\n", + (s64)now.tv_sec, (unsigned long)now.tv_nsec); seq_printf(seq, "read RPCs in flight: %d\n", cli->cl_r_in_flight); seq_printf(seq, "write RPCs in flight: %d\n", @@ -616,6 +631,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) for (i = 0; i < OBD_HIST_MAX; i++) { unsigned long r = cli->cl_read_page_hist.oh_buckets[i]; unsigned long w = cli->cl_write_page_hist.oh_buckets[i]; + read_cum += r; write_cum += w; seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", @@ -639,6 +655,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) for (i = 0; i < OBD_HIST_MAX; i++) { unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i]; unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i]; + read_cum += r; write_cum += w; seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", @@ -662,6 +679,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) for (i = 0; i < OBD_HIST_MAX; i++) { unsigned long r = cli->cl_read_offset_hist.oh_buckets[i]; unsigned long w = cli->cl_write_offset_hist.oh_buckets[i]; + read_cum += r; write_cum += w; seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", @@ -676,11 +694,12 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) return 0; } + #undef pct static ssize_t osc_rpc_stats_seq_write(struct file *file, - const char __user *buf, - size_t len, loff_t *off) + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; struct obd_device *dev = seq->private; @@ -700,14 +719,14 @@ LPROC_SEQ_FOPS(osc_rpc_stats); static int osc_stats_seq_show(struct seq_file *seq, void *v) { - struct timeval now; + struct timespec64 now; struct obd_device *dev = seq->private; struct osc_stats *stats = &obd2osc_dev(dev)->od_stats; - do_gettimeofday(&now); + ktime_get_real_ts64(&now); - seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, (unsigned long)now.tv_usec); + seq_printf(seq, "snapshot_time: %llu.%9lu (secs.usecs)\n", + (s64)now.tv_sec, (unsigned long)now.tv_nsec); seq_printf(seq, "lockless_write_bytes\t\t%llu\n", stats->os_lockless_writes); seq_printf(seq, "lockless_read_bytes\t\t%llu\n", @@ -718,8 +737,8 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v) } static ssize_t osc_stats_seq_write(struct file *file, - const char __user *buf, - size_t len, loff_t *off) + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; struct obd_device *dev = seq->private; @@ -735,17 +754,38 @@ int lproc_osc_attach_seqstat(struct obd_device *dev) { int rc; - rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0644, - &osc_stats_fops, dev); + rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "osc_stats", 0644, + &osc_stats_fops, dev); if (rc == 0) - rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644, - &osc_rpc_stats_fops, dev); + rc = ldebugfs_obd_seq_create(dev, "rpc_stats", 0644, + &osc_rpc_stats_fops, dev); return rc; } +static struct attribute *osc_attrs[] = { + &lustre_attr_active.attr, + &lustre_attr_checksums.attr, + &lustre_attr_contention_seconds.attr, + &lustre_attr_cur_dirty_bytes.attr, + &lustre_attr_cur_grant_bytes.attr, + &lustre_attr_cur_lost_grant_bytes.attr, + &lustre_attr_destroys_in_flight.attr, + &lustre_attr_grant_shrink_interval.attr, + &lustre_attr_lockless_truncate.attr, + &lustre_attr_max_dirty_mb.attr, + &lustre_attr_max_pages_per_rpc.attr, + &lustre_attr_max_rpcs_in_flight.attr, + &lustre_attr_resend_count.attr, + NULL, +}; + +static struct attribute_group osc_attr_group = { + .attrs = osc_attrs, +}; + void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) { - lvars->module_vars = lprocfs_osc_module_vars; + lvars->sysfs_vars = &osc_attr_group; lvars->obd_vars = lprocfs_osc_obd_vars; } diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_cache.c b/kernel/drivers/staging/lustre/lustre/osc/osc_cache.c index d44b3d4ff..b1d1a87f0 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/kernel/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -112,8 +112,8 @@ static const char *oes_strings[] = { /* ----- extent part 0 ----- */ \ __ext, EXTPARA(__ext), \ /* ----- part 1 ----- */ \ - atomic_read(&__ext->oe_refc), \ - atomic_read(&__ext->oe_users), \ + atomic_read(&__ext->oe_refc), \ + atomic_read(&__ext->oe_users), \ list_empty_marker(&__ext->oe_link), \ oes_strings[__ext->oe_state], ext_flags(__ext, __buf), \ __ext->oe_obj, \ @@ -247,6 +247,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, if (ext->oe_osclock) { struct cl_lock_descr *descr; + descr = &ext->oe_osclock->cll_descr; if (!(descr->cld_start <= ext->oe_start && descr->cld_end >= ext->oe_max_end)) { @@ -297,15 +298,14 @@ out: #define sanity_check_nolock(ext) \ osc_extent_sanity_check0(ext, __func__, __LINE__) -#define sanity_check(ext) ({ \ - int __res; \ +#define sanity_check(ext) ({ \ + int __res; \ osc_object_lock((ext)->oe_obj); \ - __res = sanity_check_nolock(ext); \ - osc_object_unlock((ext)->oe_obj); \ - __res; \ + __res = sanity_check_nolock(ext); \ + osc_object_unlock((ext)->oe_obj); \ + __res; \ }) - /** * sanity check - to make sure there is no overlapped extent in the tree. */ @@ -346,7 +346,7 @@ static struct osc_extent *osc_extent_alloc(struct osc_object *obj) { struct osc_extent *ext; - OBD_SLAB_ALLOC_PTR_GFP(ext, osc_extent_kmem, GFP_IOFS); + ext = kmem_cache_alloc(osc_extent_kmem, GFP_NOFS | __GFP_ZERO); if (ext == NULL) return NULL; @@ -365,7 +365,7 @@ static struct osc_extent *osc_extent_alloc(struct osc_object *obj) static void osc_extent_free(struct osc_extent *ext) { - OBD_SLAB_FREE_PTR(ext, osc_extent_kmem); + kmem_cache_free(osc_extent_kmem, ext); } static struct osc_extent *osc_extent_get(struct osc_extent *ext) @@ -411,7 +411,7 @@ static void osc_extent_put_trust(struct osc_extent *ext) static struct osc_extent *osc_extent_search(struct osc_object *obj, pgoff_t index) { - struct rb_node *n = obj->oo_root.rb_node; + struct rb_node *n = obj->oo_root.rb_node; struct osc_extent *tmp, *p = NULL; LASSERT(osc_object_is_locked(obj)); @@ -447,8 +447,8 @@ static struct osc_extent *osc_extent_lookup(struct osc_object *obj, /* caller must have held object lock. */ static void osc_extent_insert(struct osc_object *obj, struct osc_extent *ext) { - struct rb_node **n = &obj->oo_root.rb_node; - struct rb_node *parent = NULL; + struct rb_node **n = &obj->oo_root.rb_node; + struct rb_node *parent = NULL; struct osc_extent *tmp; LASSERT(ext->oe_intree == 0); @@ -475,6 +475,7 @@ static void osc_extent_insert(struct osc_object *obj, struct osc_extent *ext) static void osc_extent_erase(struct osc_extent *ext) { struct osc_object *obj = ext->oe_obj; + LASSERT(osc_object_is_locked(obj)); if (ext->oe_intree) { rb_erase(&ext->oe_node, &obj->oo_root); @@ -544,19 +545,19 @@ static int osc_extent_merge(const struct lu_env *env, struct osc_extent *cur, LASSERT(cur->oe_osclock == victim->oe_osclock); ppc_bits = osc_cli(obj)->cl_chunkbits - PAGE_CACHE_SHIFT; chunk_start = cur->oe_start >> ppc_bits; - chunk_end = cur->oe_end >> ppc_bits; - if (chunk_start != (victim->oe_end >> ppc_bits) + 1 && + chunk_end = cur->oe_end >> ppc_bits; + if (chunk_start != (victim->oe_end >> ppc_bits) + 1 && chunk_end + 1 != victim->oe_start >> ppc_bits) return -ERANGE; OSC_EXTENT_DUMP(D_CACHE, victim, "will be merged by %p.\n", cur); - cur->oe_start = min(cur->oe_start, victim->oe_start); - cur->oe_end = max(cur->oe_end, victim->oe_end); - cur->oe_grants += victim->oe_grants; + cur->oe_start = min(cur->oe_start, victim->oe_start); + cur->oe_end = max(cur->oe_end, victim->oe_end); + cur->oe_grants += victim->oe_grants; cur->oe_nr_pages += victim->oe_nr_pages; /* only the following bits are needed to merge */ - cur->oe_urgent |= victim->oe_urgent; + cur->oe_urgent |= victim->oe_urgent; cur->oe_memalloc |= victim->oe_memalloc; list_splice_init(&victim->oe_pages, &cur->oe_pages); list_del_init(&victim->oe_link); @@ -624,18 +625,18 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, { struct client_obd *cli = osc_cli(obj); - struct cl_lock *lock; + struct cl_lock *lock; struct osc_extent *cur; struct osc_extent *ext; struct osc_extent *conflict = NULL; struct osc_extent *found = NULL; - pgoff_t chunk; - pgoff_t max_end; - int max_pages; /* max_pages_per_rpc */ - int chunksize; - int ppc_bits; /* pages per chunk bits */ - int chunk_mask; - int rc; + pgoff_t chunk; + pgoff_t max_end; + int max_pages; /* max_pages_per_rpc */ + int chunksize; + int ppc_bits; /* pages per chunk bits */ + int chunk_mask; + int rc; cur = osc_extent_alloc(obj); if (cur == NULL) @@ -646,10 +647,10 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, LASSERT(lock->cll_descr.cld_mode >= CLM_WRITE); LASSERT(cli->cl_chunkbits >= PAGE_CACHE_SHIFT); - ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; + ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; chunk_mask = ~((1 << ppc_bits) - 1); - chunksize = 1 << cli->cl_chunkbits; - chunk = index >> ppc_bits; + chunksize = 1 << cli->cl_chunkbits; + chunk = index >> ppc_bits; /* align end to rpc edge, rpc size may not be a power 2 integer. */ max_pages = cli->cl_max_pages_per_rpc; @@ -659,15 +660,15 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, /* initialize new extent by parameters so far */ cur->oe_max_end = max_end; - cur->oe_start = index & chunk_mask; - cur->oe_end = ((index + ~chunk_mask + 1) & chunk_mask) - 1; + cur->oe_start = index & chunk_mask; + cur->oe_end = ((index + ~chunk_mask + 1) & chunk_mask) - 1; if (cur->oe_start < lock->cll_descr.cld_start) cur->oe_start = lock->cll_descr.cld_start; if (cur->oe_end > max_end) cur->oe_end = max_end; cur->oe_osclock = lock; - cur->oe_grants = 0; - cur->oe_mppr = max_pages; + cur->oe_grants = 0; + cur->oe_mppr = max_pages; /* grants has been allocated by caller */ LASSERTF(*grants >= chunksize + cli->cl_extent_tax, @@ -681,7 +682,7 @@ restart: ext = first_extent(obj); while (ext != NULL) { loff_t ext_chk_start = ext->oe_start >> ppc_bits; - loff_t ext_chk_end = ext->oe_end >> ppc_bits; + loff_t ext_chk_end = ext->oe_end >> ppc_bits; LASSERT(sanity_check_nolock(ext) == 0); if (chunk > ext_chk_end + 1) @@ -755,14 +756,14 @@ restart: EASSERT((ext->oe_start & ~chunk_mask) == 0, ext); /* pull ext's start back to cover cur */ - ext->oe_start = cur->oe_start; + ext->oe_start = cur->oe_start; ext->oe_grants += chunksize; *grants -= chunksize; found = osc_extent_hold(ext); } else if (chunk == ext_chk_end + 1) { /* rear merge */ - ext->oe_end = cur->oe_end; + ext->oe_end = cur->oe_end; ext->oe_grants += chunksize; *grants -= chunksize; @@ -868,6 +869,7 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, int offset = oap->oap_page_off & ~CFS_PAGE_MASK; int count = oap->oap_count + (offset & (blocksize - 1)); int end = (offset + oap->oap_count) & (blocksize - 1); + if (end) count += blocksize - end; @@ -943,21 +945,21 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, * @size, then partial truncate happens. */ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, - bool partial) + bool partial) { - struct cl_env_nest nest; - struct lu_env *env; - struct cl_io *io; - struct osc_object *obj = ext->oe_obj; - struct client_obd *cli = osc_cli(obj); + struct cl_env_nest nest; + struct lu_env *env; + struct cl_io *io; + struct osc_object *obj = ext->oe_obj; + struct client_obd *cli = osc_cli(obj); struct osc_async_page *oap; struct osc_async_page *tmp; - int pages_in_chunk = 0; - int ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; - __u64 trunc_chunk = trunc_index >> ppc_bits; - int grants = 0; - int nr_pages = 0; - int rc = 0; + int pages_in_chunk = 0; + int ppc_bits = cli->cl_chunkbits - PAGE_CACHE_SHIFT; + __u64 trunc_chunk = trunc_index >> ppc_bits; + int grants = 0; + int nr_pages = 0; + int rc = 0; LASSERT(sanity_check(ext) == 0); EASSERT(ext->oe_state == OES_TRUNC, ext); @@ -976,8 +978,8 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, /* discard all pages with index greater then trunc_index */ list_for_each_entry_safe(oap, tmp, &ext->oe_pages, oap_pending_item) { - struct cl_page *sub = oap2cl_page(oap); - struct cl_page *page = cl_page_top(sub); + struct cl_page *sub = oap2cl_page(oap); + struct cl_page *page = cl_page_top(sub); LASSERT(list_empty(&oap->oap_rpc_item)); @@ -1022,10 +1024,9 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, grants = ext->oe_grants; ext->oe_grants = 0; } else { /* calculate how many grants we can free */ - int chunks = (ext->oe_end >> ppc_bits) - trunc_chunk; + int chunks = (ext->oe_end >> ppc_bits) - trunc_chunk; pgoff_t last_index; - /* if there is no pages in this chunk, we can also free grants * for the last chunk */ if (pages_in_chunk == 0) { @@ -1038,10 +1039,10 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, } /* this is what we can free from this extent */ - grants = chunks << cli->cl_chunkbits; + grants = chunks << cli->cl_chunkbits; ext->oe_grants -= grants; - last_index = ((trunc_chunk + 1) << ppc_bits) - 1; - ext->oe_end = min(last_index, ext->oe_max_end); + last_index = ((trunc_chunk + 1) << ppc_bits) - 1; + ext->oe_end = min(last_index, ext->oe_max_end); LASSERT(ext->oe_end >= ext->oe_start); LASSERT(ext->oe_grants > 0); } @@ -1236,8 +1237,8 @@ static inline int osc_is_ready(struct osc_object *osc) static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap, int cmd) { - struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = cl_page_top(oap2cl_page(oap)); + struct osc_page *opg = oap2osc_page(oap); + struct cl_page *page = cl_page_top(oap2cl_page(oap)); int result; LASSERT(cmd == OBD_BRW_WRITE); /* no cached reads */ @@ -1251,10 +1252,10 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap, static int osc_refresh_count(const struct lu_env *env, struct osc_async_page *oap, int cmd) { - struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = oap2cl_page(oap); + struct osc_page *opg = oap2osc_page(oap); + struct cl_page *page = oap2cl_page(oap); struct cl_object *obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int result; loff_t kms; @@ -1283,10 +1284,10 @@ static int osc_refresh_count(const struct lu_env *env, static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, int cmd, int rc) { - struct osc_page *opg = oap2osc_page(oap); - struct cl_page *page = cl_page_top(oap2cl_page(oap)); - struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); - enum cl_req_type crt; + struct osc_page *opg = oap2osc_page(oap); + struct cl_page *page = cl_page_top(oap2cl_page(oap)); + struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); + enum cl_req_type crt; int srvlock; cmd &= ~OBD_BRW_NOQUOTA; @@ -1318,7 +1319,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, /* statistic */ if (rc == 0 && srvlock) { - struct lu_device *ld = opg->ops_cl.cpl_obj->co_lu.lo_dev; + struct lu_device *ld = opg->ops_cl.cpl_obj->co_lu.lo_dev; struct osc_stats *stats = &lu2osc_dev(ld)->od_stats; int bytes = oap->oap_count; @@ -1396,7 +1397,7 @@ static int osc_reserve_grant(struct client_obd *cli, unsigned int bytes) int rc = -EDQUOT; if (cli->cl_avail_grant >= bytes) { - cli->cl_avail_grant -= bytes; + cli->cl_avail_grant -= bytes; cli->cl_reserved_grant += bytes; rc = 0; } @@ -1510,6 +1511,7 @@ static int osc_enter_cache_try(struct client_obd *cli, static int ocw_granted(struct client_obd *cli, struct osc_cache_waiter *ocw) { int rc; + client_obd_list_lock(&cli->cl_loi_list_lock); rc = list_empty(&ocw->ocw_entry); client_obd_list_unlock(&cli->cl_loi_list_lock); @@ -1527,7 +1529,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, struct osc_async_page *oap, int bytes) { struct osc_object *osc = oap->oap_obj; - struct lov_oinfo *loi = osc->oo_oinfo; + struct lov_oinfo *loi = osc->oo_oinfo; struct osc_cache_waiter ocw; struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); int rc = -EDQUOT; @@ -1632,6 +1634,7 @@ wakeup: static int osc_max_rpc_in_flight(struct client_obd *cli, struct osc_object *osc) { int hprpc = !!list_empty(&osc->oo_hp_exts); + return rpcs_in_flight(cli) >= cli->cl_max_rpcs_in_flight + hprpc; } @@ -1693,6 +1696,7 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, static void osc_update_pending(struct osc_object *obj, int cmd, int delta) { struct client_obd *cli = osc_cli(obj); + if (cmd & OBD_BRW_WRITE) { atomic_add(delta, &obj->oo_nr_writes); atomic_add(delta, &cli->cl_pending_w_pages); @@ -1775,14 +1779,13 @@ static void osc_process_ar(struct osc_async_rc *ar, __u64 xid, ar->ar_force_sync = 0; } - /* this must be called holding the loi list lock to give coverage to exit_cache, * async_flag maintenance, and oap_request */ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, struct osc_async_page *oap, int sent, int rc) { struct osc_object *osc = oap->oap_obj; - struct lov_oinfo *loi = osc->oo_oinfo; + struct lov_oinfo *loi = osc->oo_oinfo; __u64 xid = 0; if (oap->oap_request != NULL) { @@ -1837,12 +1840,6 @@ static int try_to_add_extent_for_io(struct client_obd *cli, oap2 = list_first_entry(&tmp->oe_pages, struct osc_async_page, oap_pending_item); EASSERT(tmp->oe_owner == current, tmp); -#if 0 - if (overlapped(tmp, ext)) { - OSC_EXTENT_DUMP(D_ERROR, tmp, "overlapped %p.\n", ext); - EASSERT(0, ext); - } -#endif if (oap2cl_page(oap)->cp_type != oap2cl_page(oap2)->cp_type) { CDEBUG(D_CACHE, "Do not permit different type of IO" " for a same RPC\n"); @@ -1940,7 +1937,7 @@ static int get_write_extents(struct osc_object *obj, struct list_head *rpclist) static int osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, - struct osc_object *osc, pdl_policy_t pol) + struct osc_object *osc) { LIST_HEAD(rpclist); struct osc_extent *ext; @@ -1992,7 +1989,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, if (!list_empty(&rpclist)) { LASSERT(page_count > 0); - rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_WRITE, pol); + rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_WRITE); LASSERT(list_empty(&rpclist)); } @@ -2012,7 +2009,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, */ static int osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, - struct osc_object *osc, pdl_policy_t pol) + struct osc_object *osc) { struct osc_extent *ext; struct osc_extent *next; @@ -2039,7 +2036,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, osc_object_unlock(osc); LASSERT(page_count > 0); - rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_READ, pol); + rc = osc_build_rpc(env, cli, &rpclist, OBD_BRW_READ); LASSERT(list_empty(&rpclist)); osc_object_lock(osc); @@ -2049,7 +2046,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, #define list_to_obj(list, item) ({ \ struct list_head *__tmp = (list)->next; \ - list_del_init(__tmp); \ + list_del_init(__tmp); \ list_entry(__tmp, struct osc_object, oo_##item); \ }) @@ -2085,8 +2082,7 @@ static struct osc_object *osc_next_obj(struct client_obd *cli) } /* called with the loi list lock held */ -static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, - pdl_policy_t pol) +static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli) { struct osc_object *osc; int rc = 0; @@ -2115,7 +2111,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, * do io on writes while there are cache waiters */ osc_object_lock(osc); if (osc_makes_rpc(cli, osc, OBD_BRW_WRITE)) { - rc = osc_send_write_rpc(env, cli, osc, pol); + rc = osc_send_write_rpc(env, cli, osc); if (rc < 0) { CERROR("Write request failed with %d\n", rc); @@ -2139,7 +2135,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, } } if (osc_makes_rpc(cli, osc, OBD_BRW_READ)) { - rc = osc_send_read_rpc(env, cli, osc, pol); + rc = osc_send_read_rpc(env, cli, osc); if (rc < 0) CERROR("Read request failed with %d\n", rc); } @@ -2155,7 +2151,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, } static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli, - struct osc_object *osc, pdl_policy_t pol, int async) + struct osc_object *osc, int async) { int rc = 0; @@ -2167,7 +2163,7 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli, * potential stack overrun problem. LU-2859 */ atomic_inc(&cli->cl_lru_shrinkers); client_obd_list_lock(&cli->cl_loi_list_lock); - osc_check_rpcs(env, cli, pol); + osc_check_rpcs(env, cli); client_obd_list_unlock(&cli->cl_loi_list_lock); atomic_dec(&cli->cl_lru_shrinkers); } else { @@ -2179,22 +2175,21 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli, } static int osc_io_unplug_async(const struct lu_env *env, - struct client_obd *cli, struct osc_object *osc) + struct client_obd *cli, struct osc_object *osc) { - /* XXX: policy is no use actually. */ - return osc_io_unplug0(env, cli, osc, PDL_POLICY_ROUND, 1); + return osc_io_unplug0(env, cli, osc, 1); } void osc_io_unplug(const struct lu_env *env, struct client_obd *cli, - struct osc_object *osc, pdl_policy_t pol) + struct osc_object *osc) { - (void)osc_io_unplug0(env, cli, osc, pol, 0); + (void)osc_io_unplug0(env, cli, osc, 0); } int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, struct page *page, loff_t offset) { - struct obd_export *exp = osc_export(osc); + struct obd_export *exp = osc_export(osc); struct osc_async_page *oap = &ops->ops_oap; if (!page) @@ -2224,16 +2219,16 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, struct osc_page *ops) { struct osc_io *oio = osc_env_io(env); - struct osc_extent *ext = NULL; + struct osc_extent *ext = NULL; struct osc_async_page *oap = &ops->ops_oap; - struct client_obd *cli = oap->oap_cli; - struct osc_object *osc = oap->oap_obj; + struct client_obd *cli = oap->oap_cli; + struct osc_object *osc = oap->oap_obj; pgoff_t index; - int grants = 0; - int brw_flags = OBD_BRW_ASYNC; - int cmd = OBD_BRW_WRITE; - int need_release = 0; - int rc = 0; + int grants = 0; + int brw_flags = OBD_BRW_ASYNC; + int cmd = OBD_BRW_WRITE; + int need_release = 0; + int rc = 0; if (oap->oap_magic != OAP_MAGIC) return -EINVAL; @@ -2256,7 +2251,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, /* check if the file's owner/group is over quota */ if (!(cmd & OBD_BRW_NOQUOTA)) { struct cl_object *obj; - struct cl_attr *attr; + struct cl_attr *attr; unsigned int qid[MAXQUOTAS]; obj = cl_object_top(&osc->oo_cl); @@ -2386,7 +2381,7 @@ int osc_teardown_async_page(const struct lu_env *env, struct osc_object *obj, struct osc_page *ops) { struct osc_async_page *oap = &ops->ops_oap; - struct osc_extent *ext = NULL; + struct osc_extent *ext = NULL; int rc = 0; LASSERT(oap->oap_magic == OAP_MAGIC); @@ -2425,10 +2420,10 @@ int osc_teardown_async_page(const struct lu_env *env, int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, struct osc_page *ops) { - struct osc_extent *ext = NULL; - struct osc_object *obj = cl2osc(ops->ops_cl.cpl_obj); - struct cl_page *cp = ops->ops_cl.cpl_page; - pgoff_t index = cp->cp_index; + struct osc_extent *ext = NULL; + struct osc_object *obj = cl2osc(ops->ops_cl.cpl_obj); + struct cl_page *cp = ops->ops_cl.cpl_page; + pgoff_t index = cp->cp_index; struct osc_async_page *oap = &ops->ops_oap; bool unplug = false; int rc = 0; @@ -2507,14 +2502,14 @@ out: int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) { struct osc_async_page *oap = &ops->ops_oap; - struct osc_object *obj = oap->oap_obj; - struct client_obd *cli = osc_cli(obj); - struct osc_extent *ext; - struct osc_extent *found = NULL; - struct list_head *plist; + struct osc_object *obj = oap->oap_obj; + struct client_obd *cli = osc_cli(obj); + struct osc_extent *ext; + struct osc_extent *found = NULL; + struct list_head *plist; pgoff_t index = oap2cl_page(oap)->cp_index; - int rc = -EBUSY; - int cmd; + int rc = -EBUSY; + int cmd; LASSERT(!oap->oap_interrupted); oap->oap_interrupted = 1; @@ -2523,10 +2518,10 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) osc_object_lock(obj); if (oap->oap_cmd & OBD_BRW_WRITE) { plist = &obj->oo_urgent_exts; - cmd = OBD_BRW_WRITE; + cmd = OBD_BRW_WRITE; } else { plist = &obj->oo_reading_exts; - cmd = OBD_BRW_READ; + cmd = OBD_BRW_READ; } list_for_each_entry(ext, plist, oe_link) { if (ext->oe_start <= index && ext->oe_end >= index) { @@ -2564,16 +2559,17 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, struct list_head *list, int cmd, int brw_flags) { - struct client_obd *cli = osc_cli(obj); - struct osc_extent *ext; + struct client_obd *cli = osc_cli(obj); + struct osc_extent *ext; struct osc_async_page *oap, *tmp; - int page_count = 0; - int mppr = cli->cl_max_pages_per_rpc; - pgoff_t start = CL_PAGE_EOF; - pgoff_t end = 0; + int page_count = 0; + int mppr = cli->cl_max_pages_per_rpc; + pgoff_t start = CL_PAGE_EOF; + pgoff_t end = 0; list_for_each_entry(oap, list, oap_pending_item) { struct cl_page *cp = oap2cl_page(oap); + if (cp->cp_index > end) end = cp->cp_index; if (cp->cp_index < start) @@ -2785,7 +2781,7 @@ int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, { struct osc_extent *ext; pgoff_t index = start; - int result = 0; + int result = 0; again: osc_object_lock(obj); @@ -2859,6 +2855,7 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, result += ext->oe_nr_pages; if (!discard) { struct list_head *list = NULL; + if (hp) { EASSERT(!ext->oe_hp, ext); ext->oe_hp = 1; @@ -2928,10 +2925,11 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, } if (unplug) - osc_io_unplug(env, osc_cli(obj), obj, PDL_POLICY_ROUND); + osc_io_unplug(env, osc_cli(obj), obj); if (hp || discard) { int rc; + rc = osc_cache_wait_range(env, obj, start, end); if (result >= 0 && rc < 0) result = rc; diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/kernel/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 365b2787b..d2d68452d 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/kernel/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -329,7 +329,6 @@ struct osc_lock { struct osc_io *ols_owner; }; - /** * Page state private for osc layer. */ @@ -454,7 +453,7 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, pgoff_t start, pgoff_t end); void osc_io_unplug(const struct lu_env *env, struct client_obd *cli, - struct osc_object *osc, pdl_policy_t pol); + struct osc_object *osc); void osc_object_set_contended (struct osc_object *obj); void osc_object_clear_contended(struct osc_object *obj); diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_dev.c b/kernel/drivers/staging/lustre/lustre/osc/osc_dev.c index 4935fc7c0..69b523c0f 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/kernel/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -118,11 +118,11 @@ static struct lu_device *osc2lu_dev(struct osc_device *osc) */ static void *osc_key_init(const struct lu_context *ctx, - struct lu_context_key *key) + struct lu_context_key *key) { struct osc_thread_info *info; - OBD_SLAB_ALLOC_PTR_GFP(info, osc_thread_kmem, GFP_NOFS); + info = kmem_cache_alloc(osc_thread_kmem, GFP_NOFS | __GFP_ZERO); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; @@ -133,7 +133,7 @@ static void osc_key_fini(const struct lu_context *ctx, { struct osc_thread_info *info = data; - OBD_SLAB_FREE_PTR(info, osc_thread_kmem); + kmem_cache_free(osc_thread_kmem, info); } struct lu_context_key osc_key = { @@ -147,7 +147,7 @@ static void *osc_session_init(const struct lu_context *ctx, { struct osc_session *info; - OBD_SLAB_ALLOC_PTR_GFP(info, osc_session_kmem, GFP_NOFS); + info = kmem_cache_alloc(osc_session_kmem, GFP_NOFS | __GFP_ZERO); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; @@ -158,7 +158,7 @@ static void osc_session_fini(const struct lu_context *ctx, { struct osc_session *info = data; - OBD_SLAB_FREE_PTR(info, osc_session_kmem); + kmem_cache_free(osc_session_kmem, info); } struct lu_context_key osc_session_key = { @@ -204,7 +204,7 @@ static struct lu_device *osc_device_free(const struct lu_env *env, struct osc_device *od = lu2osc_dev(d); cl_device_fini(lu2cl_dev(d)); - OBD_FREE_PTR(od); + kfree(od); return NULL; } @@ -217,8 +217,8 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env, struct obd_device *obd; int rc; - OBD_ALLOC_PTR(od); - if (od == NULL) + od = kzalloc(sizeof(*od), GFP_NOFS); + if (!od) return ERR_PTR(-ENOMEM); cl_device_init(&od->od_cl, t); @@ -248,14 +248,14 @@ static const struct lu_device_type_operations osc_device_type_ops = { .ldto_device_alloc = osc_device_alloc, .ldto_device_free = osc_device_free, - .ldto_device_init = osc_device_init, - .ldto_device_fini = osc_device_fini + .ldto_device_init = osc_device_init, + .ldto_device_fini = osc_device_fini }; struct lu_device_type osc_device_type = { - .ldt_tags = LU_DEVICE_CL, - .ldt_name = LUSTRE_OSC_NAME, - .ldt_ops = &osc_device_type_ops, + .ldt_tags = LU_DEVICE_CL, + .ldt_name = LUSTRE_OSC_NAME, + .ldt_ops = &osc_device_type_ops, .ldt_ctx_tags = LCT_CL_THREAD }; diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_internal.h b/kernel/drivers/staging/lustre/lustre/osc/osc_internal.h index af96c7bc7..5ed30ecc8 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/kernel/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -39,6 +39,10 @@ #define OAP_MAGIC 8675309 +extern atomic_t osc_pool_req_count; +extern unsigned int osc_reqpool_maxreqcount; +extern struct ptlrpc_request_pool *osc_rq_pool; + struct lu_env; enum async_flags { @@ -128,7 +132,7 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *cfg); int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, - struct list_head *ext_list, int cmd, pdl_policy_t p); + struct list_head *ext_list, int cmd); int osc_lru_shrink(struct client_obd *cli, int target); extern spinlock_t osc_ast_guard; @@ -136,16 +140,8 @@ extern spinlock_t osc_ast_guard; int osc_cleanup(struct obd_device *obd); int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg); -#if defined (CONFIG_PROC_FS) int lproc_osc_attach_seqstat(struct obd_device *dev); void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;} -static inline void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif extern struct lu_device_type osc_device_type; @@ -189,6 +185,7 @@ struct osc_quota_info { struct hlist_node oqi_hash; u32 oqi_id; }; + int osc_quota_setup(struct obd_device *obd); int osc_quota_cleanup(struct obd_device *obd); int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_io.c b/kernel/drivers/staging/lustre/lustre/osc/osc_io.c index 3c7300b06..d413496c0 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/kernel/drivers/staging/lustre/lustre/osc/osc_io.c @@ -78,7 +78,6 @@ static struct osc_page *osc_cl_page_osc(struct cl_page *page) return cl2osc_page(slice); } - /***************************************************************************** * * io operations. @@ -100,16 +99,16 @@ static int osc_io_submit(const struct lu_env *env, const struct cl_io_slice *ios, enum cl_req_type crt, struct cl_2queue *queue) { - struct cl_page *page; - struct cl_page *tmp; - struct client_obd *cli = NULL; - struct osc_object *osc = NULL; /* to keep gcc happy */ - struct osc_page *opg; - struct cl_io *io; + struct cl_page *page; + struct cl_page *tmp; + struct client_obd *cli = NULL; + struct osc_object *osc = NULL; /* to keep gcc happy */ + struct osc_page *opg; + struct cl_io *io; LIST_HEAD(list); - struct cl_page_list *qin = &queue->c2_qin; - struct cl_page_list *qout = &queue->c2_qout; + struct cl_page_list *qin = &queue->c2_qin; + struct cl_page_list *qout = &queue->c2_qout; int queued = 0; int result = 0; int cmd; @@ -189,8 +188,8 @@ static int osc_io_submit(const struct lu_env *env, static void osc_page_touch_at(const struct lu_env *env, struct cl_object *obj, pgoff_t idx, unsigned to) { - struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int valid; __u64 kms; @@ -233,8 +232,8 @@ static void osc_page_touch_at(const struct lu_env *env, static void osc_page_touch(const struct lu_env *env, struct osc_page *opage, unsigned to) { - struct cl_page *page = opage->ops_cl.cpl_page; - struct cl_object *obj = opage->ops_cl.cpl_obj; + struct cl_page *page = opage->ops_cl.cpl_page; + struct cl_object *obj = opage->ops_cl.cpl_obj; osc_page_touch_at(env, obj, page->cp_index, to); } @@ -260,7 +259,7 @@ static int osc_io_prepare_write(const struct lu_env *env, { struct osc_device *dev = lu2osc_dev(slice->cpl_obj->co_lu.lo_dev); struct obd_import *imp = class_exp2cliimp(dev->od_exp); - struct osc_io *oio = cl2osc_io(env, ios); + struct osc_io *oio = cl2osc_io(env, ios); int result = 0; /* @@ -284,9 +283,9 @@ static int osc_io_commit_write(const struct lu_env *env, const struct cl_page_slice *slice, unsigned from, unsigned to) { - struct osc_io *oio = cl2osc_io(env, ios); - struct osc_page *opg = cl2osc_page(slice); - struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); + struct osc_io *oio = cl2osc_io(env, ios); + struct osc_page *opg = cl2osc_page(slice); + struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); struct osc_async_page *oap = &opg->ops_oap; LASSERT(to > 0); @@ -311,10 +310,10 @@ static int osc_io_commit_write(const struct lu_env *env, static int osc_io_fault_start(const struct lu_env *env, const struct cl_io_slice *ios) { - struct cl_io *io; + struct cl_io *io; struct cl_fault_io *fio; - io = ios->cis_io; + io = ios->cis_io; fio = &io->u.ci_fault; CDEBUG(D_INFO, "%lu %d %d\n", fio->ft_index, fio->ft_writable, fio->ft_nob); @@ -375,11 +374,11 @@ static void osc_trunc_check(const struct lu_env *env, struct cl_io *io, struct osc_io *oio, __u64 size) { struct cl_object *clob; - int partial; + int partial; pgoff_t start; - clob = oio->oi_cl.cis_obj; - start = cl_index(clob, size); + clob = oio->oi_cl.cis_obj; + start = cl_index(clob, size); partial = cl_offset(clob, start) < size; /* @@ -392,17 +391,17 @@ static void osc_trunc_check(const struct lu_env *env, struct cl_io *io, static int osc_io_setattr_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_io *io = slice->cis_io; - struct osc_io *oio = cl2osc_io(env, slice); - struct cl_object *obj = slice->cis_obj; - struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; - struct obdo *oa = &oio->oi_oa; + struct cl_io *io = slice->cis_io; + struct osc_io *oio = cl2osc_io(env, slice); + struct cl_object *obj = slice->cis_obj; + struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct obdo *oa = &oio->oi_oa; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; - __u64 size = io->u.ci_setattr.sa_attr.lvb_size; - unsigned int ia_valid = io->u.ci_setattr.sa_valid; - int result = 0; - struct obd_info oinfo = { { { 0 } } }; + __u64 size = io->u.ci_setattr.sa_attr.lvb_size; + unsigned int ia_valid = io->u.ci_setattr.sa_valid; + int result = 0; + struct obd_info oinfo = { }; /* truncate cache dirty pages first */ if (cl_io_is_trunc(io)) @@ -457,7 +456,6 @@ static int osc_io_setattr_start(const struct lu_env *env, } oinfo.oi_oa = oa; - oinfo.oi_capa = io->u.ci_setattr.sa_capa; init_completion(&cbargs->opc_sync); if (ia_valid & ATTR_SIZE) @@ -477,8 +475,8 @@ static int osc_io_setattr_start(const struct lu_env *env, static void osc_io_setattr_end(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_io *io = slice->cis_io; - struct osc_io *oio = cl2osc_io(env, slice); + struct cl_io *io = slice->cis_io; + struct osc_io *oio = cl2osc_io(env, slice); struct cl_object *obj = slice->cis_obj; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; int result = 0; @@ -512,13 +510,13 @@ static void osc_io_setattr_end(const struct lu_env *env, static int osc_io_read_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_object *obj = slice->cis_obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_object *obj = slice->cis_obj; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int rc = 0; if (!slice->cis_io->ci_noatime) { cl_object_attr_lock(obj); - attr->cat_atime = LTIME_S(CURRENT_TIME); + attr->cat_atime = ktime_get_real_seconds(); rc = cl_object_attr_set(env, obj, attr, CAT_ATIME); cl_object_attr_unlock(obj); } @@ -528,13 +526,13 @@ static int osc_io_read_start(const struct lu_env *env, static int osc_io_write_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_object *obj = slice->cis_obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_object *obj = slice->cis_obj; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; int rc = 0; OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1); cl_object_attr_lock(obj); - attr->cat_mtime = attr->cat_ctime = LTIME_S(CURRENT_TIME); + attr->cat_mtime = attr->cat_ctime = ktime_get_real_seconds(); rc = cl_object_attr_set(env, obj, attr, CAT_MTIME | CAT_CTIME); cl_object_attr_unlock(obj); @@ -544,10 +542,10 @@ static int osc_io_write_start(const struct lu_env *env, static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, struct cl_fsync_io *fio) { - struct osc_io *oio = osc_env_io(env); - struct obdo *oa = &oio->oi_oa; - struct obd_info *oinfo = &oio->oi_info; - struct lov_oinfo *loi = obj->oo_oinfo; + struct osc_io *oio = osc_env_io(env); + struct obdo *oa = &oio->oi_oa; + struct obd_info *oinfo = &oio->oi_info; + struct lov_oinfo *loi = obj->oo_oinfo; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; int rc = 0; @@ -564,7 +562,6 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, memset(oinfo, 0, sizeof(*oinfo)); oinfo->oi_oa = oa; - oinfo->oi_capa = fio->fi_capa; init_completion(&cbargs->opc_sync); rc = osc_sync_base(osc_export(obj), oinfo, osc_async_upcall, cbargs, @@ -575,13 +572,13 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, static int osc_io_fsync_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct cl_io *io = slice->cis_io; + struct cl_io *io = slice->cis_io; struct cl_fsync_io *fio = &io->u.ci_fsync; - struct cl_object *obj = slice->cis_obj; - struct osc_object *osc = cl2osc(obj); - pgoff_t start = cl_index(obj, fio->fi_start); - pgoff_t end = cl_index(obj, fio->fi_end); - int result = 0; + struct cl_object *obj = slice->cis_obj; + struct osc_object *osc = cl2osc(obj); + pgoff_t start = cl_index(obj, fio->fi_start); + pgoff_t end = cl_index(obj, fio->fi_end); + int result = 0; if (fio->fi_end == OBD_OBJECT_EOF) end = CL_PAGE_EOF; @@ -615,15 +612,15 @@ static void osc_io_fsync_end(const struct lu_env *env, const struct cl_io_slice *slice) { struct cl_fsync_io *fio = &slice->cis_io->u.ci_fsync; - struct cl_object *obj = slice->cis_obj; + struct cl_object *obj = slice->cis_obj; pgoff_t start = cl_index(obj, fio->fi_start); - pgoff_t end = cl_index(obj, fio->fi_end); + pgoff_t end = cl_index(obj, fio->fi_end); int result = 0; if (fio->fi_mode == CL_FSYNC_LOCAL) { result = osc_cache_wait_range(env, cl2osc(obj), start, end); } else if (fio->fi_mode == CL_FSYNC_ALL) { - struct osc_io *oio = cl2osc_io(env, slice); + struct osc_io *oio = cl2osc_io(env, slice); struct osc_async_cbargs *cbargs = &oio->oi_cbarg; wait_for_completion(&cbargs->opc_sync); @@ -703,7 +700,7 @@ static void osc_req_completion(const struct lu_env *env, struct osc_req *or; or = cl2osc_req(slice); - OBD_SLAB_FREE_PTR(or, osc_req_kmem); + kmem_cache_free(osc_req_kmem, or); } /** @@ -717,17 +714,17 @@ static void osc_req_attr_set(const struct lu_env *env, struct cl_req_attr *attr, u64 flags) { struct lov_oinfo *oinfo; - struct cl_req *clerq; - struct cl_page *apage; /* _some_ page in @clerq */ - struct cl_lock *lock; /* _some_ lock protecting @apage */ - struct osc_lock *olck; - struct osc_page *opg; - struct obdo *oa; - struct ost_lvb *lvb; - - oinfo = cl2osc(obj)->oo_oinfo; - lvb = &oinfo->loi_lvb; - oa = attr->cra_oa; + struct cl_req *clerq; + struct cl_page *apage; /* _some_ page in @clerq */ + struct cl_lock *lock; /* _some_ lock protecting @apage */ + struct osc_lock *olck; + struct osc_page *opg; + struct obdo *oa; + struct ost_lvb *lvb; + + oinfo = cl2osc(obj)->oo_oinfo; + lvb = &oinfo->loi_lvb; + oa = attr->cra_oa; if ((flags & OBD_MD_FLMTIME) != 0) { oa->o_mtime = lvb->lvb_mtime; @@ -759,7 +756,7 @@ static void osc_req_attr_set(const struct lu_env *env, lock = cl_lock_at_page(env, apage->cp_obj, apage, NULL, 1, 1); if (lock == NULL) { struct cl_object_header *head; - struct cl_lock *scan; + struct cl_lock *scan; head = cl_object_header(apage->cp_obj); list_for_each_entry(scan, &head->coh_locks, @@ -790,7 +787,6 @@ static const struct cl_req_operations osc_req_ops = { .cro_completion = osc_req_completion }; - int osc_io_init(const struct lu_env *env, struct cl_object *obj, struct cl_io *io) { @@ -807,7 +803,7 @@ int osc_req_init(const struct lu_env *env, struct cl_device *dev, struct osc_req *or; int result; - OBD_SLAB_ALLOC_PTR_GFP(or, osc_req_kmem, GFP_NOFS); + or = kmem_cache_alloc(osc_req_kmem, GFP_NOFS | __GFP_ZERO); if (or != NULL) { cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops); result = 0; diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_lock.c b/kernel/drivers/staging/lustre/lustre/osc/osc_lock.c index 350ad4955..194490dca 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/kernel/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -89,9 +89,9 @@ static struct ldlm_lock *osc_handle_ptr(struct lustre_handle *handle) */ static int osc_lock_invariant(struct osc_lock *ols) { - struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle); - struct ldlm_lock *olock = ols->ols_lock; - int handle_used = lustre_handle_is_used(&ols->ols_handle); + struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle); + struct ldlm_lock *olock = ols->ols_lock; + int handle_used = lustre_handle_is_used(&ols->ols_handle); if (ergo(osc_lock_is_lockless(ols), ols->ols_locklessable && ols->ols_lock == NULL)) @@ -164,7 +164,7 @@ static void osc_lock_detach(const struct lu_env *env, struct osc_lock *olck) lock_res_and_lock(dlmlock); if (dlmlock->l_granted_mode == dlmlock->l_req_mode) { struct cl_object *obj = olck->ols_cl.cls_obj; - struct cl_attr *attr = &osc_env_info(env)->oti_attr; + struct cl_attr *attr = &osc_env_info(env)->oti_attr; __u64 old_kms; cl_object_attr_lock(obj); @@ -237,7 +237,7 @@ static int osc_lock_unuse(const struct lu_env *env, static void osc_lock_fini(const struct lu_env *env, struct cl_lock_slice *slice) { - struct osc_lock *ols = cl2osc_lock(slice); + struct osc_lock *ols = cl2osc_lock(slice); LINVRNT(osc_lock_invariant(ols)); /* @@ -251,7 +251,7 @@ static void osc_lock_fini(const struct lu_env *env, LASSERT(atomic_read(&ols->ols_pageref) == 0 || atomic_read(&ols->ols_pageref) == _PAGEREF_MAGIC); - OBD_SLAB_FREE_PTR(ols, osc_lock_kmem); + kmem_cache_free(osc_lock_kmem, ols); } static void osc_lock_build_policy(const struct lu_env *env, @@ -337,25 +337,25 @@ static void osc_ast_data_put(const struct lu_env *env, struct osc_lock *olck) static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, int rc) { - struct ost_lvb *lvb; - struct cl_object *obj; - struct lov_oinfo *oinfo; - struct cl_attr *attr; - unsigned valid; + struct ost_lvb *lvb; + struct cl_object *obj; + struct lov_oinfo *oinfo; + struct cl_attr *attr; + unsigned valid; if (!(olck->ols_flags & LDLM_FL_LVB_READY)) return; - lvb = &olck->ols_lvb; - obj = olck->ols_cl.cls_obj; + lvb = &olck->ols_lvb; + obj = olck->ols_cl.cls_obj; oinfo = cl2osc(obj)->oo_oinfo; - attr = &osc_env_info(env)->oti_attr; + attr = &osc_env_info(env)->oti_attr; valid = CAT_BLOCKS | CAT_ATIME | CAT_CTIME | CAT_MTIME | CAT_SIZE; cl_lvb2attr(attr, lvb); cl_object_attr_lock(obj); if (rc == 0) { - struct ldlm_lock *dlmlock; + struct ldlm_lock *dlmlock; __u64 size; dlmlock = olck->ols_lock; @@ -401,23 +401,23 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, static void osc_lock_granted(const struct lu_env *env, struct osc_lock *olck, struct ldlm_lock *dlmlock, int rc) { - struct ldlm_extent *ext; - struct cl_lock *lock; + struct ldlm_extent *ext; + struct cl_lock *lock; struct cl_lock_descr *descr; LASSERT(dlmlock->l_granted_mode == dlmlock->l_req_mode); if (olck->ols_state < OLS_GRANTED) { - lock = olck->ols_cl.cls_lock; - ext = &dlmlock->l_policy_data.l_extent; + lock = olck->ols_cl.cls_lock; + ext = &dlmlock->l_policy_data.l_extent; descr = &osc_env_info(env)->oti_descr; descr->cld_obj = lock->cll_descr.cld_obj; /* XXX check that ->l_granted_mode is valid. */ - descr->cld_mode = osc_ldlm2cl_lock(dlmlock->l_granted_mode); + descr->cld_mode = osc_ldlm2cl_lock(dlmlock->l_granted_mode); descr->cld_start = cl_index(descr->cld_obj, ext->start); - descr->cld_end = cl_index(descr->cld_obj, ext->end); - descr->cld_gid = ext->gid; + descr->cld_end = cl_index(descr->cld_obj, ext->end); + descr->cld_gid = ext->gid; /* * tell upper layers the extent of the lock that was actually * granted @@ -482,11 +482,11 @@ static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck) */ static int osc_lock_upcall(void *cookie, int errcode) { - struct osc_lock *olck = cookie; - struct cl_lock_slice *slice = &olck->ols_cl; - struct cl_lock *lock = slice->cls_lock; - struct lu_env *env; - struct cl_env_nest nest; + struct osc_lock *olck = cookie; + struct cl_lock_slice *slice = &olck->ols_cl; + struct cl_lock *lock = slice->cls_lock; + struct lu_env *env; + struct cl_env_nest nest; env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { @@ -626,7 +626,7 @@ static int osc_dlm_blocking_ast0(const struct lu_env *env, void *data, int flag) { struct osc_lock *olck; - struct cl_lock *lock; + struct cl_lock *lock; int result; int cancel; @@ -733,9 +733,9 @@ static int osc_ldlm_blocking_ast(struct ldlm_lock *dlmlock, struct ldlm_lock_desc *new, void *data, int flag) { - struct lu_env *env; + struct lu_env *env; struct cl_env_nest nest; - int result; + int result; /* * This can be called in the context of outer IO, e.g., @@ -774,9 +774,9 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock, __u64 flags, void *data) { struct cl_env_nest nest; - struct lu_env *env; - struct osc_lock *olck; - struct cl_lock *lock; + struct lu_env *env; + struct osc_lock *olck; + struct cl_lock *lock; int result; int dlmrc; @@ -830,15 +830,15 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock, static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) { - struct ptlrpc_request *req = data; + struct ptlrpc_request *req = data; struct osc_lock *olck; - struct cl_lock *lock; - struct cl_object *obj; - struct cl_env_nest nest; - struct lu_env *env; - struct ost_lvb *lvb; - struct req_capsule *cap; - int result; + struct cl_lock *lock; + struct cl_object *obj; + struct cl_env_nest nest; + struct lu_env *env; + struct ost_lvb *lvb; + struct req_capsule *cap; + int result; LASSERT(lustre_msg_get_opc(req->rq_reqmsg) == LDLM_GL_CALLBACK); @@ -916,11 +916,11 @@ static void osc_lock_build_einfo(const struct lu_env *env, */ mode = CLM_READ; - einfo->ei_type = LDLM_EXTENT; - einfo->ei_mode = osc_cl_lock2ldlm(mode); - einfo->ei_cb_bl = osc_ldlm_blocking_ast; - einfo->ei_cb_cp = osc_ldlm_completion_ast; - einfo->ei_cb_gl = osc_ldlm_glimpse_ast; + einfo->ei_type = LDLM_EXTENT; + einfo->ei_mode = osc_cl_lock2ldlm(mode); + einfo->ei_cb_bl = osc_ldlm_blocking_ast; + einfo->ei_cb_cp = osc_ldlm_completion_ast; + einfo->ei_cb_gl = osc_ldlm_glimpse_ast; einfo->ei_cbdata = lock; /* value to be put into ->l_ast_data */ } @@ -948,9 +948,9 @@ static void osc_lock_to_lockless(const struct lu_env *env, ols->ols_locklessable = 1; slice->cls_ops = &osc_lock_lockless_ops; } else { - struct osc_io *oio = osc_env_io(env); - struct cl_io *io = oio->oi_cl.cis_io; - struct cl_object *obj = slice->cls_obj; + struct osc_io *oio = osc_env_io(env); + struct cl_io *io = oio->oi_cl.cis_io; + struct cl_object *obj = slice->cls_obj; struct osc_object *oob = cl2osc(obj); const struct osc_device *osd = lu2osc_dev(obj->co_lu.lo_dev); struct obd_connect_data *ocd; @@ -1006,13 +1006,13 @@ static int osc_lock_compatible(const struct osc_lock *qing, static int osc_lock_enqueue_wait(const struct lu_env *env, const struct osc_lock *olck) { - struct cl_lock *lock = olck->ols_cl.cls_lock; - struct cl_lock_descr *descr = &lock->cll_descr; - struct cl_object_header *hdr = cl_object_header(descr->cld_obj); - struct cl_lock *scan; - struct cl_lock *conflict = NULL; - int lockless = osc_lock_is_lockless(olck); - int rc = 0; + struct cl_lock *lock = olck->ols_cl.cls_lock; + struct cl_lock_descr *descr = &lock->cll_descr; + struct cl_object_header *hdr = cl_object_header(descr->cld_obj); + struct cl_lock *scan; + struct cl_lock *conflict = NULL; + int lockless = osc_lock_is_lockless(olck); + int rc = 0; LASSERT(cl_lock_is_mutexed(lock)); @@ -1102,8 +1102,8 @@ static int osc_lock_enqueue(const struct lu_env *env, const struct cl_lock_slice *slice, struct cl_io *unused, __u32 enqflags) { - struct osc_lock *ols = cl2osc_lock(slice); - struct cl_lock *lock = ols->ols_cl.cls_lock; + struct osc_lock *ols = cl2osc_lock(slice); + struct cl_lock *lock = ols->ols_cl.cls_lock; int result; LASSERT(cl_lock_is_mutexed(lock)); @@ -1116,10 +1116,10 @@ static int osc_lock_enqueue(const struct lu_env *env, result = osc_lock_enqueue_wait(env, ols); if (result == 0) { if (!osc_lock_is_lockless(ols)) { - struct osc_object *obj = cl2osc(slice->cls_obj); - struct osc_thread_info *info = osc_env_info(env); - struct ldlm_res_id *resname = &info->oti_resname; - ldlm_policy_data_t *policy = &info->oti_policy; + struct osc_object *obj = cl2osc(slice->cls_obj); + struct osc_thread_info *info = osc_env_info(env); + struct ldlm_res_id *resname = &info->oti_resname; + ldlm_policy_data_t *policy = &info->oti_policy; struct ldlm_enqueue_info *einfo = &ols->ols_einfo; /* lock will be passed as upcall cookie, @@ -1164,7 +1164,7 @@ static int osc_lock_wait(const struct lu_env *env, const struct cl_lock_slice *slice) { struct osc_lock *olck = cl2osc_lock(slice); - struct cl_lock *lock = olck->ols_cl.cls_lock; + struct cl_lock *lock = olck->ols_cl.cls_lock; LINVRNT(osc_lock_invariant(olck)); @@ -1176,8 +1176,7 @@ static int osc_lock_wait(const struct lu_env *env, /* It is from enqueue RPC reply upcall for * updating state. Do not re-enqueue. */ return -ENAVAIL; - else - olck->ols_state = OLS_NEW; + olck->ols_state = OLS_NEW; } else { LASSERT(lock->cll_error); return lock->cll_error; @@ -1245,14 +1244,14 @@ static int osc_lock_use(const struct lu_env *env, static int osc_lock_flush(struct osc_lock *ols, int discard) { - struct cl_lock *lock = ols->ols_cl.cls_lock; - struct cl_env_nest nest; - struct lu_env *env; + struct cl_lock *lock = ols->ols_cl.cls_lock; + struct cl_env_nest nest; + struct lu_env *env; int result = 0; env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { - struct osc_object *obj = cl2osc(ols->ols_cl.cls_obj); + struct osc_object *obj = cl2osc(ols->ols_cl.cls_obj); struct cl_lock_descr *descr = &lock->cll_descr; int rc = 0; @@ -1298,11 +1297,11 @@ static int osc_lock_flush(struct osc_lock *ols, int discard) static void osc_lock_cancel(const struct lu_env *env, const struct cl_lock_slice *slice) { - struct cl_lock *lock = slice->cls_lock; - struct osc_lock *olck = cl2osc_lock(slice); + struct cl_lock *lock = slice->cls_lock; + struct osc_lock *olck = cl2osc_lock(slice); struct ldlm_lock *dlmlock = olck->ols_lock; - int result = 0; - int discard; + int result = 0; + int discard; LASSERT(cl_lock_is_mutexed(lock)); LINVRNT(osc_lock_invariant(olck)); @@ -1482,7 +1481,7 @@ static int osc_lock_lockless_unuse(const struct lu_env *env, static void osc_lock_lockless_cancel(const struct lu_env *env, const struct cl_lock_slice *slice) { - struct osc_lock *ols = cl2osc_lock(slice); + struct osc_lock *ols = cl2osc_lock(slice); int result; result = osc_lock_flush(ols, 0); @@ -1496,7 +1495,7 @@ static int osc_lock_lockless_wait(const struct lu_env *env, const struct cl_lock_slice *slice) { struct osc_lock *olck = cl2osc_lock(slice); - struct cl_lock *lock = olck->ols_cl.cls_lock; + struct cl_lock *lock = olck->ols_cl.cls_lock; LINVRNT(osc_lock_invariant(olck)); LASSERT(olck->ols_state >= OLS_UPCALL_RECEIVED); @@ -1512,7 +1511,7 @@ static void osc_lock_lockless_state(const struct lu_env *env, LINVRNT(osc_lock_invariant(lock)); if (state == CLS_HELD) { - struct osc_io *oio = osc_env_io(env); + struct osc_io *oio = osc_env_io(env); LASSERT(ergo(lock->ols_owner, lock->ols_owner == oio)); lock->ols_owner = oio; @@ -1556,7 +1555,7 @@ int osc_lock_init(const struct lu_env *env, struct osc_lock *clk; int result; - OBD_SLAB_ALLOC_PTR_GFP(clk, osc_lock_kmem, GFP_NOFS); + clk = kmem_cache_alloc(osc_lock_kmem, GFP_NOFS | __GFP_ZERO); if (clk != NULL) { __u32 enqflags = lock->cll_descr.cld_enq_flags; @@ -1591,7 +1590,7 @@ int osc_lock_init(const struct lu_env *env, int osc_dlm_lock_pageref(struct ldlm_lock *dlm) { struct osc_lock *olock; - int rc = 0; + int rc = 0; spin_lock(&osc_ast_guard); olock = dlm->l_ast_data; diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_object.c b/kernel/drivers/staging/lustre/lustre/osc/osc_object.c index 92c202f70..ba57f8df5 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/kernel/drivers/staging/lustre/lustre/osc/osc_object.c @@ -72,7 +72,7 @@ static struct osc_object *lu2osc(const struct lu_object *obj) static int osc_object_init(const struct lu_env *env, struct lu_object *obj, const struct lu_object_conf *conf) { - struct osc_object *osc = lu2osc(obj); + struct osc_object *osc = lu2osc(obj); const struct cl_object_conf *cconf = lu2cl_conf(conf); int i; @@ -122,7 +122,7 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj) LASSERT(atomic_read(&osc->oo_nr_writes) == 0); lu_object_fini(obj); - OBD_SLAB_FREE_PTR(osc, osc_object_kmem); + kmem_cache_free(osc_object_kmem, osc); } int osc_lvb_print(const struct lu_env *env, void *cookie, @@ -136,9 +136,9 @@ int osc_lvb_print(const struct lu_env *env, void *cookie, static int osc_object_print(const struct lu_env *env, void *cookie, lu_printer_t p, const struct lu_object *obj) { - struct osc_object *osc = lu2osc(obj); - struct lov_oinfo *oinfo = osc->oo_oinfo; - struct osc_async_rc *ar = &oinfo->loi_ar; + struct osc_object *osc = lu2osc(obj); + struct lov_oinfo *oinfo = osc->oo_oinfo; + struct osc_async_rc *ar = &oinfo->loi_ar; (*p)(env, cookie, "id: " DOSTID " idx: %d gen: %d kms_valid: %u kms %llu rc: %d force_sync: %d min_xid: %llu ", POSTID(&oinfo->loi_oi), oinfo->loi_ost_idx, @@ -148,7 +148,6 @@ static int osc_object_print(const struct lu_env *env, void *cookie, return 0; } - static int osc_attr_get(const struct lu_env *env, struct cl_object *obj, struct cl_attr *attr) { @@ -163,7 +162,7 @@ int osc_attr_set(const struct lu_env *env, struct cl_object *obj, const struct cl_attr *attr, unsigned valid) { struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo; - struct ost_lvb *lvb = &oinfo->loi_lvb; + struct ost_lvb *lvb = &oinfo->loi_lvb; if (valid & CAT_SIZE) lvb->lvb_size = attr->cat_size; @@ -188,12 +187,11 @@ static int osc_object_glimpse(const struct lu_env *env, { struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo; - lvb->lvb_size = oinfo->loi_kms; + lvb->lvb_size = oinfo->loi_kms; lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks; return 0; } - void osc_object_set_contended(struct osc_object *obj) { obj->oo_contention_time = cfs_time_current(); @@ -208,9 +206,9 @@ void osc_object_clear_contended(struct osc_object *obj) int osc_object_is_contended(struct osc_object *obj) { - struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev); + struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev); int osc_contention_time = dev->od_contention_time; - unsigned long cur_time = cfs_time_current(); + unsigned long cur_time = cfs_time_current(); unsigned long retry_time; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION)) @@ -255,9 +253,9 @@ struct lu_object *osc_object_alloc(const struct lu_env *env, struct lu_device *dev) { struct osc_object *osc; - struct lu_object *obj; + struct lu_object *obj; - OBD_SLAB_ALLOC_PTR_GFP(osc, osc_object_kmem, GFP_NOFS); + osc = kmem_cache_alloc(osc_object_kmem, GFP_NOFS | __GFP_ZERO); if (osc != NULL) { obj = osc2lu(osc); lu_object_init(obj, NULL, dev); diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_page.c b/kernel/drivers/staging/lustre/lustre/osc/osc_page.c index 76ba58b09..61eaf7172 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/kernel/drivers/staging/lustre/lustre/osc/osc_page.c @@ -166,6 +166,7 @@ static void osc_page_fini(const struct lu_env *env, struct cl_page_slice *slice) { struct osc_page *opg = cl2osc_page(slice); + CDEBUG(D_TRACE, "%p\n", opg); LASSERT(opg->ops_lock == NULL); } @@ -216,7 +217,7 @@ static int osc_page_cache_add(const struct lu_env *env, const struct cl_page_slice *slice, struct cl_io *io) { - struct osc_io *oio = osc_env_io(env); + struct osc_io *oio = osc_env_io(env); struct osc_page *opg = cl2osc_page(slice); int result; @@ -247,7 +248,7 @@ void osc_index2policy(ldlm_policy_data_t *policy, const struct cl_object *obj, { memset(policy, 0, sizeof(*policy)); policy->l_extent.start = cl_offset(obj, start); - policy->l_extent.end = cl_offset(obj, end + 1) - 1; + policy->l_extent.end = cl_offset(obj, end + 1) - 1; } static int osc_page_addref_lock(const struct lu_env *env, @@ -255,7 +256,7 @@ static int osc_page_addref_lock(const struct lu_env *env, struct cl_lock *lock) { struct osc_lock *olock; - int rc; + int rc; LASSERT(opg->ops_lock == NULL); @@ -274,7 +275,7 @@ static int osc_page_addref_lock(const struct lu_env *env, static void osc_page_putref_lock(const struct lu_env *env, struct osc_page *opg) { - struct cl_lock *lock = opg->ops_lock; + struct cl_lock *lock = opg->ops_lock; struct osc_lock *olock; LASSERT(lock != NULL); @@ -291,7 +292,7 @@ static int osc_page_is_under_lock(const struct lu_env *env, struct cl_io *unused) { struct cl_lock *lock; - int result = -ENODATA; + int result = -ENODATA; lock = cl_lock_at_page(env, slice->cpl_obj, slice->cpl_page, NULL, 1, 0); @@ -317,7 +318,7 @@ static void osc_page_completion_read(const struct lu_env *env, const struct cl_page_slice *slice, int ioret) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); if (likely(opg->ops_lock)) @@ -329,7 +330,7 @@ static void osc_page_completion_write(const struct lu_env *env, const struct cl_page_slice *slice, int ioret) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(slice->cpl_obj); osc_lru_add(osc_cli(obj), opg); @@ -346,7 +347,6 @@ static int osc_page_fail(const struct lu_env *env, return 0; } - static const char *osc_list(struct list_head *head) { return list_empty(head) ? "-" : "+"; @@ -364,10 +364,10 @@ static int osc_page_print(const struct lu_env *env, const struct cl_page_slice *slice, void *cookie, lu_printer_t printer) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_async_page *oap = &opg->ops_oap; - struct osc_object *obj = cl2osc(slice->cpl_obj); - struct client_obd *cli = &osc_export(obj)->exp_obd->u.cli; + struct osc_object *obj = cl2osc(slice->cpl_obj); + struct client_obd *cli = &osc_export(obj)->exp_obd->u.cli; return (*printer)(env, cookie, LUSTRE_OSC_NAME "-page@%p: 1< %#x %d %u %s %s > 2< %llu %u %u %#x %#x | %p %p %p > 3< %s %p %d %lu %d > 4< %d %d %d %lu %s | %s %s %s %s > 5< %s %s %s %s | %d %s | %d %s %s>\n", opg, @@ -408,7 +408,7 @@ static int osc_page_print(const struct lu_env *env, static void osc_page_delete(const struct lu_env *env, const struct cl_page_slice *slice) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); int rc; @@ -437,13 +437,13 @@ static void osc_page_delete(const struct lu_env *env, void osc_page_clip(const struct lu_env *env, const struct cl_page_slice *slice, int from, int to) { - struct osc_page *opg = cl2osc_page(slice); + struct osc_page *opg = cl2osc_page(slice); struct osc_async_page *oap = &opg->ops_oap; LINVRNT(osc_page_protected(env, opg, CLM_READ, 0)); opg->ops_from = from; - opg->ops_to = to; + opg->ops_to = to; spin_lock(&oap->oap_lock); oap->oap_async_flags |= ASYNC_COUNT_STABLE; spin_unlock(&oap->oap_lock); @@ -471,7 +471,7 @@ static int osc_page_flush(const struct lu_env *env, struct cl_io *io) { struct osc_page *opg = cl2osc_page(slice); - int rc = 0; + int rc; rc = osc_flush_async_page(env, io, opg); return rc; @@ -502,16 +502,17 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj, struct cl_page *page, struct page *vmpage) { struct osc_object *osc = cl2osc(obj); - struct osc_page *opg = cl_object_page_slice(obj, page); + struct osc_page *opg = cl_object_page_slice(obj, page); int result; opg->ops_from = 0; - opg->ops_to = PAGE_CACHE_SIZE; + opg->ops_to = PAGE_CACHE_SIZE; result = osc_prep_async_page(osc, opg, vmpage, cl_offset(obj, page->cp_index)); if (result == 0) { struct osc_io *oio = osc_env_io(env); + opg->ops_srvlock = osc_io_srvlock(oio); cl_page_slice_add(page, &opg->ops_cl, obj, &osc_page_ops); @@ -540,7 +541,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, enum cl_req_type crt, int brw_flags) { struct osc_async_page *oap = &opg->ops_oap; - struct osc_object *obj = oap->oap_obj; + struct osc_object *obj = oap->oap_obj; LINVRNT(osc_page_protected(env, opg, crt == CRT_WRITE ? CLM_WRITE : CLM_READ, 1)); @@ -550,10 +551,10 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, LASSERT(oap->oap_async_flags & ASYNC_READY); LASSERT(oap->oap_async_flags & ASYNC_COUNT_STABLE); - oap->oap_cmd = crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ; - oap->oap_page_off = opg->ops_from; - oap->oap_count = opg->ops_to - opg->ops_from; - oap->oap_brw_flags = OBD_BRW_SYNC | brw_flags; + oap->oap_cmd = crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ; + oap->oap_page_off = opg->ops_from; + oap->oap_count = opg->ops_to - opg->ops_from; + oap->oap_brw_flags = brw_flags | OBD_BRW_SYNC; if (!client_is_remote(osc_export(obj)) && capable(CFS_CAP_SYS_RESOURCE)) { @@ -624,6 +625,7 @@ static int discard_pagevec(const struct lu_env *env, struct cl_io *io, for (count = 0, i = 0; i < max_index; i++) { struct cl_page *page = pvec[i]; + if (cl_page_own_try(env, io, page) == 0) { /* free LRU page only if nobody is using it. * This check is necessary to avoid freeing the pages @@ -818,7 +820,6 @@ static int osc_lru_reclaim(struct client_obd *cli) int rc; LASSERT(cache != NULL); - LASSERT(!list_empty(&cache->ccc_lru)); rc = osc_lru_shrink(cli, lru_shrink_min); if (rc != 0) { @@ -835,6 +836,8 @@ static int osc_lru_reclaim(struct client_obd *cli) /* Reclaim LRU slots from other client_obd as it can't free enough * from its own. This should rarely happen. */ spin_lock(&cache->ccc_lru_lock); + LASSERT(!list_empty(&cache->ccc_lru)); + cache->ccc_lru_shrinkers++; list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru); diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_quota.c b/kernel/drivers/staging/lustre/lustre/osc/osc_quota.c index 6690f149a..199783103 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/kernel/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -35,7 +35,7 @@ static inline struct osc_quota_info *osc_oqi_alloc(u32 id) { struct osc_quota_info *oqi; - OBD_SLAB_ALLOC_PTR(oqi, osc_quota_kmem); + oqi = kmem_cache_alloc(osc_quota_kmem, GFP_NOFS | __GFP_ZERO); if (oqi != NULL) oqi->oqi_id = id; @@ -104,7 +104,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], /* race with others? */ if (rc == -EALREADY) { rc = 0; - OBD_SLAB_FREE_PTR(oqi, osc_quota_kmem); + kmem_cache_free(osc_quota_kmem, oqi); } CDEBUG(D_QUOTA, "%s: setdq to insert for %s %d (%d)\n", @@ -120,7 +120,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], oqi = cfs_hash_del_key(cli->cl_quota_hash[type], &qid[type]); if (oqi) - OBD_SLAB_FREE_PTR(oqi, osc_quota_kmem); + kmem_cache_free(osc_quota_kmem, oqi); CDEBUG(D_QUOTA, "%s: setdq to remove for %s %d (%p)\n", cli->cl_import->imp_obd->obd_name, @@ -158,6 +158,7 @@ static void * oqi_key(struct hlist_node *hnode) { struct osc_quota_info *oqi; + oqi = hlist_entry(hnode, struct osc_quota_info, oqi_hash); return &oqi->oqi_id; } @@ -185,14 +186,14 @@ oqi_exit(struct cfs_hash *hs, struct hlist_node *hnode) oqi = hlist_entry(hnode, struct osc_quota_info, oqi_hash); - OBD_SLAB_FREE_PTR(oqi, osc_quota_kmem); + kmem_cache_free(osc_quota_kmem, oqi); } #define HASH_QUOTA_BKT_BITS 5 #define HASH_QUOTA_CUR_BITS 5 #define HASH_QUOTA_MAX_BITS 15 -static cfs_hash_ops_t quota_hash_ops = { +static struct cfs_hash_ops quota_hash_ops = { .hs_hash = oqi_hashfn, .hs_keycmp = oqi_keycmp, .hs_key = oqi_key, @@ -232,7 +233,7 @@ int osc_quota_setup(struct obd_device *obd) int osc_quota_cleanup(struct obd_device *obd) { - struct client_obd *cli = &obd->u.cli; + struct client_obd *cli = &obd->u.cli; int type; for (type = 0; type < MAXQUOTAS; type++) @@ -245,8 +246,8 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, struct obd_quotactl *oqctl) { struct ptlrpc_request *req; - struct obd_quotactl *oqc; - int rc; + struct obd_quotactl *oqc; + int rc; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACTL, LUSTRE_OST_VERSION, @@ -285,10 +286,10 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, struct obd_quotactl *oqctl) { - struct client_obd *cli = &exp->exp_obd->u.cli; - struct ptlrpc_request *req; - struct obd_quotactl *body; - int rc; + struct client_obd *cli = &exp->exp_obd->u.cli; + struct ptlrpc_request *req; + struct obd_quotactl *body; + int rc; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACHECK, LUSTRE_OST_VERSION, diff --git a/kernel/drivers/staging/lustre/lustre/osc/osc_request.c b/kernel/drivers/staging/lustre/lustre/osc/osc_request.c index d7a9b650d..367f83af1 100644 --- a/kernel/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/kernel/drivers/staging/lustre/lustre/osc/osc_request.c @@ -38,7 +38,6 @@ #include "../../include/linux/libcfs/libcfs.h" - #include "../include/lustre_dlm.h" #include "../include/lustre_net.h" #include "../include/lustre/lustre_user.h" @@ -50,9 +49,18 @@ #include "../include/lustre_param.h" #include "../include/lustre_fid.h" #include "../include/obd_class.h" +#include "../include/obd.h" #include "osc_internal.h" #include "osc_cl_internal.h" +atomic_t osc_pool_req_count; +unsigned int osc_reqpool_maxreqcount; +struct ptlrpc_request_pool *osc_rq_pool; + +/* max memory used for request pool, unit is MB */ +static unsigned int osc_reqpool_mem_max = 5; +module_param(osc_reqpool_mem_max, uint, 0444); + struct osc_brw_async_args { struct obdo *aa_oa; int aa_requested_nob; @@ -63,7 +71,6 @@ struct osc_brw_async_args { struct client_obd *aa_cli; struct list_head aa_oaps; struct list_head aa_exts; - struct obd_capa *aa_ocapa; struct cl_req *aa_clerq; }; @@ -110,7 +117,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, return lmm_size; if (*lmmp != NULL && lsm == NULL) { - OBD_FREE(*lmmp, lmm_size); + kfree(*lmmp); *lmmp = NULL; return 0; } else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) { @@ -118,8 +125,8 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, } if (*lmmp == NULL) { - OBD_ALLOC(*lmmp, lmm_size); - if (*lmmp == NULL) + *lmmp = kzalloc(lmm_size, GFP_NOFS); + if (!*lmmp) return -ENOMEM; } @@ -157,19 +164,20 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, return lsm_size; if (*lsmp != NULL && lmm == NULL) { - OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); - OBD_FREE(*lsmp, lsm_size); + kfree((*lsmp)->lsm_oinfo[0]); + kfree(*lsmp); *lsmp = NULL; return 0; } if (*lsmp == NULL) { - OBD_ALLOC(*lsmp, lsm_size); + *lsmp = kzalloc(lsm_size, GFP_NOFS); if (unlikely(*lsmp == NULL)) return -ENOMEM; - OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); + (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), + GFP_NOFS); if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) { - OBD_FREE(*lsmp, lsm_size); + kfree(*lsmp); return -ENOMEM; } loi_init((*lsmp)->lsm_oinfo[0]); @@ -190,22 +198,6 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, return lsm_size; } -static inline void osc_pack_capa(struct ptlrpc_request *req, - struct ost_body *body, void *capa) -{ - struct obd_capa *oc = (struct obd_capa *)capa; - struct lustre_capa *c; - - if (!capa) - return; - - c = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1); - LASSERT(c); - capa_cpy(c, oc); - body->oa.o_valid |= OBD_MD_FLOSSCAPA; - DEBUG_CAPA(D_SEC, c, "pack"); -} - static inline void osc_pack_req_body(struct ptlrpc_request *req, struct obd_info *oinfo) { @@ -216,18 +208,6 @@ static inline void osc_pack_req_body(struct ptlrpc_request *req, lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oinfo->oi_oa); - osc_pack_capa(req, body, oinfo->oi_capa); -} - -static inline void osc_set_capa_size(struct ptlrpc_request *req, - const struct req_msg_field *field, - struct obd_capa *oc) -{ - if (oc == NULL) - req_capsule_set_size(&req->rq_pill, field, RCL_CLIENT, 0); - else - /* it is already calculated as sizeof struct obd_capa */ - ; } static int osc_getattr_interpret(const struct lu_env *env, @@ -263,13 +243,12 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, { struct ptlrpc_request *req; struct osc_async_args *aa; - int rc; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) return -ENOMEM; - osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); if (rc) { ptlrpc_request_free(req); @@ -293,14 +272,13 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo) { struct ptlrpc_request *req; - struct ost_body *body; - int rc; + struct ost_body *body; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) return -ENOMEM; - osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); if (rc) { ptlrpc_request_free(req); @@ -337,8 +315,8 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo, struct obd_trans_info *oti) { struct ptlrpc_request *req; - struct ost_body *body; - int rc; + struct ost_body *body; + int rc; LASSERT(oinfo->oi_oa->o_valid & OBD_MD_FLGROUP); @@ -346,7 +324,6 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, if (req == NULL) return -ENOMEM; - osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR); if (rc) { ptlrpc_request_free(req); @@ -402,15 +379,14 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, obd_enqueue_update_f upcall, void *cookie, struct ptlrpc_request_set *rqset) { - struct ptlrpc_request *req; + struct ptlrpc_request *req; struct osc_setattr_args *sa; - int rc; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); if (req == NULL) return -ENOMEM; - osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR); if (rc) { ptlrpc_request_free(req); @@ -427,19 +403,19 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, /* do mds to ost setattr asynchronously */ if (!rqset) { /* Do not wait for response. */ - ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); + ptlrpcd_add_req(req); } else { req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret; - CLASSERT (sizeof(*sa) <= sizeof(req->rq_async_args)); + CLASSERT(sizeof(*sa) <= sizeof(req->rq_async_args)); sa = ptlrpc_req_async_args(req); sa->sa_oa = oinfo->oi_oa; sa->sa_upcall = upcall; sa->sa_cookie = cookie; if (rqset == PTLRPCD_SET) - ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); + ptlrpcd_add_req(req); else ptlrpc_set_add_req(rqset, req); } @@ -459,9 +435,9 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md **ea, struct obd_trans_info *oti) { struct ptlrpc_request *req; - struct ost_body *body; - struct lov_stripe_md *lsm; - int rc; + struct ost_body *body; + struct lov_stripe_md *lsm; + int rc; LASSERT(oa); LASSERT(ea); @@ -547,16 +523,15 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, obd_enqueue_update_f upcall, void *cookie, struct ptlrpc_request_set *rqset) { - struct ptlrpc_request *req; + struct ptlrpc_request *req; struct osc_setattr_args *sa; - struct ost_body *body; - int rc; + struct ost_body *body; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_PUNCH); if (req == NULL) return -ENOMEM; - osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_PUNCH); if (rc) { ptlrpc_request_free(req); @@ -569,18 +544,17 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, LASSERT(body); lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oinfo->oi_oa); - osc_pack_capa(req, body, oinfo->oi_capa); ptlrpc_request_set_replen(req); req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret; - CLASSERT (sizeof(*sa) <= sizeof(req->rq_async_args)); + CLASSERT(sizeof(*sa) <= sizeof(req->rq_async_args)); sa = ptlrpc_req_async_args(req); - sa->sa_oa = oinfo->oi_oa; + sa->sa_oa = oinfo->oi_oa; sa->sa_upcall = upcall; sa->sa_cookie = cookie; if (rqset == PTLRPCD_SET) - ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); + ptlrpcd_add_req(req); else ptlrpc_set_add_req(rqset, req); @@ -599,7 +573,7 @@ static int osc_sync_interpret(const struct lu_env *env, body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); if (body == NULL) { - CERROR ("can't unpack ost_body\n"); + CERROR("can't unpack ost_body\n"); rc = -EPROTO; goto out; } @@ -615,15 +589,14 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, struct ptlrpc_request_set *rqset) { struct ptlrpc_request *req; - struct ost_body *body; + struct ost_body *body; struct osc_fsync_args *fa; - int rc; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SYNC); if (req == NULL) return -ENOMEM; - osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SYNC); if (rc) { ptlrpc_request_free(req); @@ -635,7 +608,6 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, LASSERT(body); lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oinfo->oi_oa); - osc_pack_capa(req, body, oinfo->oi_capa); ptlrpc_request_set_replen(req); req->rq_interpret_reply = osc_sync_interpret; @@ -647,7 +619,7 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, fa->fa_cookie = cookie; if (rqset == PTLRPCD_SET) - ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); + ptlrpcd_add_req(req); else ptlrpc_set_add_req(rqset, req); @@ -753,12 +725,11 @@ int osc_create(const struct lu_env *env, struct obd_export *exp, * cookies to the MDS after committing destroy transactions. */ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, struct obdo *oa, struct lov_stripe_md *ea, - struct obd_trans_info *oti, struct obd_export *md_export, - void *capa) + struct obd_trans_info *oti, struct obd_export *md_export) { - struct client_obd *cli = &exp->exp_obd->u.cli; + struct client_obd *cli = &exp->exp_obd->u.cli; struct ptlrpc_request *req; - struct ost_body *body; + struct ost_body *body; LIST_HEAD(cancels); int rc, count; @@ -776,7 +747,6 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, return -ENOMEM; } - osc_set_capa_size(req, &RMF_CAPA1, (struct obd_capa *)capa); rc = ldlm_prep_elc_req(exp, req, LUSTRE_OST_VERSION, OST_DESTROY, 0, &cancels, count); if (rc) { @@ -793,7 +763,6 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, LASSERT(body); lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa); - osc_pack_capa(req, body, (struct obd_capa *)capa); ptlrpc_request_set_replen(req); /* If osc_destroy is for destroying the unlink orphan, @@ -816,7 +785,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, } /* Do not wait for response */ - ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); + ptlrpcd_add_req(req); return 0; } @@ -909,7 +878,7 @@ static int osc_shrink_grant_interpret(const struct lu_env *env, LASSERT(body); osc_update_grant(cli, body); out: - OBDO_FREE(oa); + kmem_cache_free(obdo_cachep, oa); return rc; } @@ -946,7 +915,7 @@ static int osc_shrink_grant(struct client_obd *cli) int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) { - int rc = 0; + int rc = 0; struct ost_body *body; client_obd_list_lock(&cli->cl_loi_list_lock); @@ -962,7 +931,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) } client_obd_list_unlock(&cli->cl_loi_list_lock); - OBD_ALLOC_PTR(body); + body = kzalloc(sizeof(*body), GFP_NOFS); if (!body) return -ENOMEM; @@ -984,7 +953,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) sizeof(*body), body, NULL); if (rc != 0) __osc_update_grant(cli, body->oa.o_grant); - OBD_FREE_PTR(body); + kfree(body); return rc; } @@ -1006,8 +975,8 @@ static int osc_should_shrink_grant(struct client_obd *client) if (client->cl_import->imp_state == LUSTRE_IMP_FULL && client->cl_avail_grant > brw_size) return 1; - else - osc_update_next_shrink(client); + + osc_update_next_shrink(client); } return 0; } @@ -1099,7 +1068,7 @@ static void handle_short_read(int nob_read, u32 page_count, /* skip bytes read OK */ while (nob_read > 0) { - LASSERT (page_count > 0); + LASSERT(page_count > 0); if (pga[i]->count > nob_read) { /* EOF inside this page */ @@ -1130,8 +1099,8 @@ static int check_write_rcs(struct ptlrpc_request *req, int requested_nob, int niocount, u32 page_count, struct brw_page **pga) { - int i; - __u32 *remote_rcs; + int i; + __u32 *remote_rcs; remote_rcs = req_capsule_server_sized_get(&req->rq_pill, &RMF_RCS, sizeof(*remote_rcs) * @@ -1181,15 +1150,15 @@ static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2) } static u32 osc_checksum_bulk(int nob, u32 pg_count, - struct brw_page **pga, int opc, - cksum_type_t cksum_type) + struct brw_page **pga, int opc, + cksum_type_t cksum_type) { - __u32 cksum; - int i = 0; - struct cfs_crypto_hash_desc *hdesc; - unsigned int bufsize; - int err; - unsigned char cfs_alg = cksum_obd2cfs(cksum_type); + __u32 cksum; + int i = 0; + struct cfs_crypto_hash_desc *hdesc; + unsigned int bufsize; + int err; + unsigned char cfs_alg = cksum_obd2cfs(cksum_type); LASSERT(pg_count > 0); @@ -1209,6 +1178,7 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count, OBD_FAIL_CHECK(OBD_FAIL_OSC_CHECKSUM_RECEIVE)) { unsigned char *ptr = kmap(pga[i]->pg); int off = pga[i]->off & ~CFS_PAGE_MASK; + memcpy(ptr + off, "bad1", min(4, nob)); kunmap(pga[i]->pg); } @@ -1246,17 +1216,17 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, struct lov_stripe_md *lsm, u32 page_count, struct brw_page **pga, struct ptlrpc_request **reqp, - struct obd_capa *ocapa, int reserve, + int reserve, int resend) { - struct ptlrpc_request *req; + struct ptlrpc_request *req; struct ptlrpc_bulk_desc *desc; - struct ost_body *body; - struct obd_ioobj *ioobj; - struct niobuf_remote *niobuf; + struct ost_body *body; + struct obd_ioobj *ioobj; + struct niobuf_remote *niobuf; int niocount, i, requested_nob, opc, rc; struct osc_brw_async_args *aa; - struct req_capsule *pill; + struct req_capsule *pill; struct brw_page *pg_prev; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ)) @@ -1267,7 +1237,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, if ((cmd & OBD_BRW_WRITE) != 0) { opc = OST_WRITE; req = ptlrpc_request_alloc_pool(cli->cl_import, - cli->cl_import->imp_rq_pool, + osc_rq_pool, &RQF_OST_BRW_WRITE); } else { opc = OST_READ; @@ -1286,7 +1256,6 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, sizeof(*ioobj)); req_capsule_set_size(pill, &RMF_NIOBUF_REMOTE, RCL_CLIENT, niocount * sizeof(*niobuf)); - osc_set_capa_size(req, &RMF_CAPA1, ocapa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, opc); if (rc) { @@ -1325,7 +1294,6 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, * "max - 1" for old client compatibility sending "0", and also so the * the actual maximum is a power-of-two number, not one less. LU-1431 */ ioobj_max_brw_set(ioobj, desc->bd_md_max_brw); - osc_pack_capa(req, body, ocapa); LASSERT(page_count > 0); pg_prev = pga[0]; for (requested_nob = i = 0; i < page_count; i++, niobuf++) { @@ -1358,8 +1326,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, niobuf->len += pg->count; } else { niobuf->offset = pg->off; - niobuf->len = pg->count; - niobuf->flags = pg->flag; + niobuf->len = pg->count; + niobuf->flags = pg->flag; } pg_prev = pg; } @@ -1434,8 +1402,6 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, aa->aa_ppga = pga; aa->aa_cli = cli; INIT_LIST_HEAD(&aa->aa_oaps); - if (ocapa && reserve) - aa->aa_ocapa = capa_get(ocapa); *reqp = req; return 0; @@ -1570,7 +1536,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) } if (rc != req->rq_bulk->bd_nob_transferred) { - CERROR ("Unexpected rc %d (%d transferred)\n", + CERROR("Unexpected rc %d (%d transferred)\n", rc, req->rq_bulk->bd_nob_transferred); return -EPROTO; } @@ -1580,20 +1546,18 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (body->oa.o_valid & OBD_MD_FLCKSUM) { static int cksum_counter; - __u32 server_cksum = body->oa.o_cksum; - char *via; - char *router; + __u32 server_cksum = body->oa.o_cksum; + char *via = ""; + char *router = ""; cksum_type_t cksum_type; - cksum_type = cksum_type_unpack(body->oa.o_valid &OBD_MD_FLFLAGS? + cksum_type = cksum_type_unpack(body->oa.o_valid&OBD_MD_FLFLAGS ? body->oa.o_flags : 0); client_cksum = osc_checksum_bulk(rc, aa->aa_page_count, aa->aa_ppga, OST_READ, cksum_type); - if (peer->nid == req->rq_bulk->bd_sender) { - via = router = ""; - } else { + if (peer->nid != req->rq_bulk->bd_sender) { via = " via "; router = libcfs_nid2str(req->rq_bulk->bd_sender); } @@ -1653,11 +1617,11 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, "redo for recoverable error %d", rc); rc = osc_brw_prep_request(lustre_msg_get_opc(request->rq_reqmsg) == - OST_WRITE ? OBD_BRW_WRITE :OBD_BRW_READ, + OST_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ, aa->aa_cli, aa->aa_oa, NULL /* lsm unused by osc currently */, aa->aa_page_count, aa->aa_ppga, - &new_req, aa->aa_ocapa, 0, 1); + &new_req, 0, 1); if (rc) return rc; @@ -1680,9 +1644,9 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, /* cap resend delay to the current request timeout, this is similar to * what ptlrpc does (see after_reply()) */ if (aa->aa_resends > new_req->rq_timeout) - new_req->rq_sent = get_seconds() + new_req->rq_timeout; + new_req->rq_sent = ktime_get_real_seconds() + new_req->rq_timeout; else - new_req->rq_sent = get_seconds() + aa->aa_resends; + new_req->rq_sent = ktime_get_real_seconds() + aa->aa_resends; new_req->rq_generation_set = 1; new_req->rq_import_generation = request->rq_import_generation; @@ -1701,14 +1665,11 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, } } - new_aa->aa_ocapa = aa->aa_ocapa; - aa->aa_ocapa = NULL; - /* XXX: This code will run into problem if we're going to support * to add a series of BRW RPCs into a self-defined ptlrpc_request_set * and wait for all of them to be finished. We should inherit request * set from old request. */ - ptlrpcd_add_req(new_req, PDL_POLICY_SAME, -1); + ptlrpcd_add_req(new_req); DEBUG_REQ(D_INFO, new_req, "new request"); return 0; @@ -1748,7 +1709,7 @@ static void sort_brw_pages(struct brw_page **array, int num) static void osc_release_ppga(struct brw_page **ppga, u32 count) { LASSERT(ppga != NULL); - OBD_FREE(ppga, sizeof(*ppga) * count); + kfree(ppga); } static int brw_interpret(const struct lu_env *env, @@ -1757,7 +1718,7 @@ static int brw_interpret(const struct lu_env *env, struct osc_brw_async_args *aa = data; struct osc_extent *ext; struct osc_extent *tmp; - struct cl_object *obj = NULL; + struct cl_object *obj = NULL; struct client_obd *cli = aa->aa_cli; rc = osc_brw_fini_request(req, rc); @@ -1785,11 +1746,6 @@ static int brw_interpret(const struct lu_env *env, rc = -EIO; } - if (aa->aa_ocapa) { - capa_put(aa->aa_ocapa); - aa->aa_ocapa = NULL; - } - list_for_each_entry_safe(ext, tmp, &aa->aa_exts, oe_link) { if (obj == NULL && rc == 0) { obj = osc2cl(ext->oe_obj); @@ -1831,7 +1787,7 @@ static int brw_interpret(const struct lu_env *env, } cl_object_put(env, obj); } - OBDO_FREE(aa->aa_oa); + kmem_cache_free(obdo_cachep, aa->aa_oa); cl_req_completion(env, aa->aa_clerq, rc < 0 ? rc : req->rq_bulk->bd_nob_transferred); @@ -1849,7 +1805,7 @@ static int brw_interpret(const struct lu_env *env, osc_wake_cache_waiters(cli); client_obd_list_unlock(&cli->cl_loi_list_lock); - osc_io_unplug(env, cli, NULL, PDL_POLICY_SAME); + osc_io_unplug(env, cli, NULL); return rc; } @@ -1859,28 +1815,27 @@ static int brw_interpret(const struct lu_env *env, * Extents in the list must be in OES_RPC state. */ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, - struct list_head *ext_list, int cmd, pdl_policy_t pol) -{ - struct ptlrpc_request *req = NULL; - struct osc_extent *ext; - struct brw_page **pga = NULL; - struct osc_brw_async_args *aa = NULL; - struct obdo *oa = NULL; - struct osc_async_page *oap; - struct osc_async_page *tmp; - struct cl_req *clerq = NULL; - enum cl_req_type crt = (cmd & OBD_BRW_WRITE) ? CRT_WRITE : - CRT_READ; - struct ldlm_lock *lock = NULL; - struct cl_req_attr *crattr = NULL; - u64 starting_offset = OBD_OBJECT_EOF; - u64 ending_offset = 0; - int mpflag = 0; - int mem_tight = 0; - int page_count = 0; - int i; - int rc; - struct ost_body *body; + struct list_head *ext_list, int cmd) +{ + struct ptlrpc_request *req = NULL; + struct osc_extent *ext; + struct brw_page **pga = NULL; + struct osc_brw_async_args *aa = NULL; + struct obdo *oa = NULL; + struct osc_async_page *oap; + struct osc_async_page *tmp; + struct cl_req *clerq = NULL; + enum cl_req_type crt = (cmd & OBD_BRW_WRITE) ? CRT_WRITE : CRT_READ; + struct ldlm_lock *lock = NULL; + struct cl_req_attr *crattr = NULL; + u64 starting_offset = OBD_OBJECT_EOF; + u64 ending_offset = 0; + int mpflag = 0; + int mem_tight = 0; + int page_count = 0; + int i; + int rc; + struct ost_body *body; LIST_HEAD(rpc_list); LASSERT(!list_empty(ext_list)); @@ -1908,19 +1863,19 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, if (mem_tight) mpflag = cfs_memory_pressure_get_and_set(); - OBD_ALLOC(crattr, sizeof(*crattr)); - if (crattr == NULL) { + crattr = kzalloc(sizeof(*crattr), GFP_NOFS); + if (!crattr) { rc = -ENOMEM; goto out; } - OBD_ALLOC(pga, sizeof(*pga) * page_count); + pga = kcalloc(page_count, sizeof(*pga), GFP_NOFS); if (pga == NULL) { rc = -ENOMEM; goto out; } - OBDO_ALLOC(oa); + oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); if (oa == NULL) { rc = -ENOMEM; goto out; @@ -1929,6 +1884,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, i = 0; list_for_each_entry(oap, &rpc_list, oap_rpc_item) { struct cl_page *page = oap2cl_page(oap); + if (clerq == NULL) { clerq = cl_req_alloc(env, page, crt, 1 /* only 1-object rpcs for now */); @@ -1966,7 +1922,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, sort_brw_pages(pga, page_count); rc = osc_brw_prep_request(cmd, cli, oa, NULL, page_count, - pga, &req, crattr->cra_capa, 1, 0); + pga, &req, 1, 0); if (rc != 0) { CERROR("prep_req failed: %d\n", rc); goto out; @@ -2034,37 +1990,21 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, page_count, aa, cli->cl_r_in_flight, cli->cl_w_in_flight); - /* XXX: Maybe the caller can check the RPC bulk descriptor to - * see which CPU/NUMA node the majority of pages were allocated - * on, and try to assign the async RPC to the CPU core - * (PDL_POLICY_PREFERRED) to reduce cross-CPU memory traffic. - * - * But on the other hand, we expect that multiple ptlrpcd - * threads and the initial write sponsor can run in parallel, - * especially when data checksum is enabled, which is CPU-bound - * operation and single ptlrpcd thread cannot process in time. - * So more ptlrpcd threads sharing BRW load - * (with PDL_POLICY_ROUND) seems better. - */ - ptlrpcd_add_req(req, pol, -1); + ptlrpcd_add_req(req); rc = 0; out: if (mem_tight != 0) cfs_memory_pressure_restore(mpflag); - if (crattr != NULL) { - capa_put(crattr->cra_capa); - OBD_FREE(crattr, sizeof(*crattr)); - } + kfree(crattr); if (rc != 0) { LASSERT(req == NULL); if (oa) - OBDO_FREE(oa); - if (pga) - OBD_FREE(pga, sizeof(*pga) * page_count); + kmem_cache_free(obdo_cachep, oa); + kfree(pga); /* this should happen rarely and is pretty bad, it makes the * pending list not follow the dirty order */ while (!list_empty(ext_list)) { @@ -2150,6 +2090,7 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, /* The request was created before ldlm_cli_enqueue call. */ if (rc == ELDLM_LOCK_ABORTED) { struct ldlm_reply *rep; + rep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); @@ -2300,7 +2241,9 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, ldlm_lock_decref(lockh, mode); LDLM_LOCK_PUT(matched); return -ECANCELED; - } else if (osc_set_lock_data_with_check(matched, einfo)) { + } + + if (osc_set_lock_data_with_check(matched, einfo)) { *flags |= LDLM_FL_LVB_READY; /* addref the lock only if not async requests and PW * lock is matched whereas we asked for PR. */ @@ -2325,15 +2268,16 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, ldlm_lock_decref(lockh, einfo->ei_mode); LDLM_LOCK_PUT(matched); return ELDLM_OK; - } else { - ldlm_lock_decref(lockh, mode); - LDLM_LOCK_PUT(matched); } + + ldlm_lock_decref(lockh, mode); + LDLM_LOCK_PUT(matched); } no_match: if (intent) { LIST_HEAD(cancels); + req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE_LVB); if (req == NULL) @@ -2358,6 +2302,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, if (rqset) { if (!rc) { struct osc_enqueue_args *aa; + CLASSERT (sizeof(*aa) <= sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); aa->oa_ei = einfo; @@ -2372,7 +2317,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_enqueue_interpret; if (rqset == PTLRPCD_SET) - ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); + ptlrpcd_add_req(req); else ptlrpc_set_add_req(rqset, req); } else if (intent) { @@ -2480,10 +2425,10 @@ static int osc_statfs_async(struct obd_export *exp, struct obd_info *oinfo, __u64 max_age, struct ptlrpc_request_set *rqset) { - struct obd_device *obd = class_exp2obd(exp); + struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req; struct osc_async_args *aa; - int rc; + int rc; /* We could possibly pass max_age in the request (as an absolute * timestamp or a "seconds.usec ago") so the target can avoid doing @@ -2522,10 +2467,10 @@ static int osc_statfs_async(struct obd_export *exp, static int osc_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, __u64 max_age, __u32 flags) { - struct obd_device *obd = class_exp2obd(exp); - struct obd_statfs *msfs; + struct obd_device *obd = class_exp2obd(exp); + struct obd_statfs *msfs; struct ptlrpc_request *req; - struct obd_import *imp = NULL; + struct obd_import *imp = NULL; int rc; /*Since the request might also come from lprocfs, so we need @@ -2617,7 +2562,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) * because lov_user_md_vX and lov_mds_md_vX have the same size */ if (lum.lmm_stripe_count > 0) { lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic); - OBD_ALLOC(lumk, lum_size); + lumk = kzalloc(lum_size, GFP_NOFS); if (!lumk) return -ENOMEM; @@ -2639,12 +2584,11 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) rc = -EFAULT; if (lumk != &lum) - OBD_FREE(lumk, lum_size); + kfree(lumk); return rc; } - static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { @@ -2664,7 +2608,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, buf = NULL; len = 0; - if (obd_ioctl_getdata(&buf, &len, (void *)uarg)) { + if (obd_ioctl_getdata(&buf, &len, uarg)) { err = -EINVAL; goto out; } @@ -2694,7 +2638,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, memcpy(data->ioc_inlbuf2, &obd->obd_uuid, sizeof(uuid)); - err = copy_to_user((void *)uarg, buf, len); + err = copy_to_user(uarg, buf, len); if (err) err = -EFAULT; obd_ioctl_freedata(buf, len); @@ -2719,7 +2663,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, data->ioc_offset); goto out; case OBD_IOC_POLL_QUOTACHECK: - err = osc_quota_poll_check(exp, (struct if_quotacheck *)karg); + err = osc_quota_poll_check(exp, karg); goto out; case OBD_IOC_PING_TARGET: err = ptlrpc_obd_ping(obd); @@ -2749,9 +2693,9 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, return 0; } else if (KEY_IS(KEY_LAST_ID)) { struct ptlrpc_request *req; - u64 *reply; - char *tmp; - int rc; + u64 *reply; + char *tmp; + int rc; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GET_INFO_LAST_ID); @@ -2786,16 +2730,15 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, ptlrpc_req_finished(req); return rc; } else if (KEY_IS(KEY_FIEMAP)) { - struct ll_fiemap_info_key *fm_key = - (struct ll_fiemap_info_key *)key; - struct ldlm_res_id res_id; - ldlm_policy_data_t policy; - struct lustre_handle lockh; - ldlm_mode_t mode = 0; - struct ptlrpc_request *req; - struct ll_user_fiemap *reply; - char *tmp; - int rc; + struct ll_fiemap_info_key *fm_key = key; + struct ldlm_res_id res_id; + ldlm_policy_data_t policy; + struct lustre_handle lockh; + ldlm_mode_t mode = 0; + struct ptlrpc_request *req; + struct ll_user_fiemap *reply; + char *tmp; + int rc; if (!(fm_key->fiemap.fm_flags & FIEMAP_FLAG_SYNC)) goto skip_locking; @@ -2881,10 +2824,10 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, void *val, struct ptlrpc_request_set *set) { struct ptlrpc_request *req; - struct obd_device *obd = exp->exp_obd; - struct obd_import *imp = class_exp2cliimp(exp); - char *tmp; - int rc; + struct obd_device *obd = exp->exp_obd; + struct obd_import *imp = class_exp2cliimp(exp); + char *tmp; + int rc; OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_SHUTDOWN, 10); @@ -2909,7 +2852,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, struct client_obd *cli = &obd->u.cli; LASSERT(cli->cl_cache == NULL); /* only once */ - cli->cl_cache = (struct cl_client_cache *)val; + cli->cl_cache = val; atomic_inc(&cli->cl_cache->ccc_users); cli->cl_lru_left = &cli->cl_cache->ccc_lru_left; @@ -2972,7 +2915,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); - OBDO_ALLOC(oa); + oa = kmem_cache_alloc(obdo_cachep, GFP_NOFS | __GFP_ZERO); if (!oa) { ptlrpc_req_finished(req); return -ENOMEM; @@ -2987,8 +2930,9 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, LASSERT(set != NULL); ptlrpc_set_add_req(set, req); ptlrpc_check_set(NULL, set); - } else - ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); + } else { + ptlrpcd_add_req(req); + } return 0; } @@ -3071,8 +3015,8 @@ static int osc_import_event(struct obd_device *obd, } case IMP_EVENT_INVALIDATE: { struct ldlm_namespace *ns = obd->obd_namespace; - struct lu_env *env; - int refcheck; + struct lu_env *env; + int refcheck; env = cl_env_get(&refcheck); if (!IS_ERR(env)) { @@ -3080,7 +3024,7 @@ static int osc_import_event(struct obd_device *obd, cli = &obd->u.cli; /* all pages go to failing rpcs due to the invalid * import */ - osc_io_unplug(env, cli, NULL, PDL_POLICY_ROUND); + osc_io_unplug(env, cli, NULL); ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); cl_env_put(env, &refcheck); @@ -3100,7 +3044,7 @@ static int osc_import_event(struct obd_device *obd, /* See bug 7198 */ if (ocd->ocd_connect_flags & OBD_CONNECT_REQPORTAL) - imp->imp_client->cli_request_portal =OST_REQUEST_PORTAL; + imp->imp_client->cli_request_portal = OST_REQUEST_PORTAL; rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL); break; @@ -3152,16 +3096,19 @@ static int brw_queue_work(const struct lu_env *env, void *data) CDEBUG(D_CACHE, "Run writeback work for client obd %p.\n", cli); - osc_io_unplug(env, cli, NULL, PDL_POLICY_SAME); + osc_io_unplug(env, cli, NULL); return 0; } int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lprocfs_static_vars lvars = { NULL }; - struct client_obd *cli = &obd->u.cli; - void *handler; - int rc; + struct client_obd *cli = &obd->u.cli; + void *handler; + int rc; + int adding; + int added; + int req_count; rc = ptlrpcd_addref(); if (rc) @@ -3184,21 +3131,26 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL; lprocfs_osc_init_vars(&lvars); - if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) { + if (lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars) == 0) { lproc_osc_attach_seqstat(obd); sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); } - /* We need to allocate a few requests more, because - * brw_interpret tries to create new requests before freeing - * previous ones, Ideally we want to have 2x max_rpcs_in_flight - * reserved, but I'm afraid that might be too much wasted RAM - * in fact, so 2 is just my guess and still should work. */ - cli->cl_import->imp_rq_pool = - ptlrpc_init_rq_pool(cli->cl_max_rpcs_in_flight + 2, - OST_MAXREQSIZE, - ptlrpc_add_rqs_to_pool); + /* + * We try to control the total number of requests with a upper limit + * osc_reqpool_maxreqcount. There might be some race which will cause + * over-limit allocation, but it is fine. + */ + req_count = atomic_read(&osc_pool_req_count); + if (req_count < osc_reqpool_maxreqcount) { + adding = cli->cl_max_rpcs_in_flight + 2; + if (req_count + adding > osc_reqpool_maxreqcount) + adding = osc_reqpool_maxreqcount - req_count; + + added = ptlrpc_add_rqs_to_pool(osc_rq_pool, adding); + atomic_add(added, &osc_pool_req_count); + } INIT_LIST_HEAD(&cli->cl_grant_shrink_list); ns_register_cancel(obd->obd_namespace, osc_cancel_for_recovery); @@ -3218,6 +3170,7 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) switch (stage) { case OBD_CLEANUP_EARLY: { struct obd_import *imp; + imp = obd->u.cli.cl_import; CDEBUG(D_HA, "Deactivating import %s\n", obd->obd_name); /* ptlrpc_abort_inflight to stop an mds_lov_synchronize */ @@ -3338,6 +3291,8 @@ extern struct lock_class_key osc_ast_guard_class; static int __init osc_init(void) { struct lprocfs_static_vars lvars = { NULL }; + unsigned int reqpool_size; + unsigned int reqsize; int rc; /* print an address of _any_ initialized kernel symbol from this @@ -3351,16 +3306,47 @@ static int __init osc_init(void) lprocfs_osc_init_vars(&lvars); - rc = class_register_type(&osc_obd_ops, NULL, lvars.module_vars, + rc = class_register_type(&osc_obd_ops, NULL, LUSTRE_OSC_NAME, &osc_device_type); - if (rc) { - lu_kmem_fini(osc_caches); - return rc; - } + if (rc) + goto out_kmem; spin_lock_init(&osc_ast_guard); lockdep_set_class(&osc_ast_guard, &osc_ast_guard_class); + /* This is obviously too much memory, only prevent overflow here */ + if (osc_reqpool_mem_max >= 1 << 12 || osc_reqpool_mem_max == 0) { + rc = -EINVAL; + goto out_type; + } + + reqpool_size = osc_reqpool_mem_max << 20; + + reqsize = 1; + while (reqsize < OST_MAXREQSIZE) + reqsize = reqsize << 1; + + /* + * We don't enlarge the request count in OSC pool according to + * cl_max_rpcs_in_flight. The allocation from the pool will only be + * tried after normal allocation failed. So a small OSC pool won't + * cause much performance degression in most of cases. + */ + osc_reqpool_maxreqcount = reqpool_size / reqsize; + + atomic_set(&osc_pool_req_count, 0); + osc_rq_pool = ptlrpc_init_rq_pool(0, OST_MAXREQSIZE, + ptlrpc_add_rqs_to_pool); + + if (osc_rq_pool) + return 0; + + rc = -ENOMEM; + +out_type: + class_unregister_type(LUSTRE_OSC_NAME); +out_kmem: + lu_kmem_fini(osc_caches); return rc; } @@ -3368,6 +3354,7 @@ static void /*__exit*/ osc_exit(void) { class_unregister_type(LUSTRE_OSC_NAME); lu_kmem_fini(osc_caches); + ptlrpc_free_rq_pool(osc_rq_pool); } MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); |