From trent.geerdes at intel.com Thu Dec 1 19:26:39 2016 From: trent.geerdes at intel.com (Geerdes, Trent) Date: Thu, 1 Dec 2016 19:26:39 +0000 Subject: [lustre-devel] Intel HPDD Maintenance Notification In-Reply-To: References: Message-ID: <61E86E31-902F-4A09-BE8D-3334E9964F4E@intel.com> Sites are available again and maintenance has been completed. Thanks, Trent Geerdes System Administrator Team Lead Datacenter Operations (DCO) High Performance Data Division (HPDD) Intel Corporation E-mail: trent.geerdes at intel.com On 11/28/16, 10:31 AM, "Geerdes, Trent" wrote: Intel High Performance Data Division Maintenance Notification WHAT and WHEN: On Thursday Dec 1, 2016 8:00am - 1:00pm Mountain time the following sites will be unavailable. https://jira.hpdd.intel.com https://wiki.hpdd.intel.com http://review.whamcloud.com http://git.whamcloud.com http://downloads.hpdd.intel.com Jenkins (https://build.hpdd.intel.com) will be available but jobs will be paused during the maintenance window. WHY: The applications are being moved to new servers with more resources. The applications are being upgraded to newer versions. QUESTIONS: For questions or concerns contact Trent Geerdes e-mail: trent.geerdes at intel.com From jsimmons at infradead.org Thu Dec 1 22:35:32 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 1 Dec 2016 17:35:32 -0500 Subject: [lustre-devel] [PATCH 3/3] staging: lustre: osc: Performance tune for LRU In-Reply-To: <1480631732-6880-1-git-send-email-jsimmons@infradead.org> References: <1480631732-6880-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480631732-6880-4-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong Early launch page LRU work in osc_io_rw_iter_init(); Change the page LRU shrinking policy by OSC attributes; Delete the contented lock osc_object::oo_seatbelt Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5108 Reviewed-on: http://review.whamcloud.com/10458 Reviewed-by: Bobi Jam Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd.h | 8 ++ drivers/staging/lustre/lustre/osc/lproc_osc.c | 6 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 26 +--- .../staging/lustre/lustre/osc/osc_cl_internal.h | 19 --- drivers/staging/lustre/lustre/osc/osc_internal.h | 2 +- drivers/staging/lustre/lustre/osc/osc_io.c | 13 ++- drivers/staging/lustre/lustre/osc/osc_object.c | 9 -- drivers/staging/lustre/lustre/osc/osc_page.c | 119 ++++++++++++-------- drivers/staging/lustre/lustre/osc/osc_request.c | 4 +- 9 files changed, 106 insertions(+), 100 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 6d6e479..0f48e9c 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -267,6 +267,14 @@ struct client_obd { * allowed to have multiple threads shrinking LRU cache. */ atomic_t cl_lru_shrinkers; + /** The time when this LRU cache was last used. */ + time64_t cl_lru_last_used; + /** stats: how many reclaims have happened for this client_obd. + * reclaim and shrink - shrink is async, voluntarily rebalancing; + * reclaim is sync, initiated by IO thread when the LRU slots are + * in shortage. + */ + u64 cl_lru_reclaim; /** List of LRU pages for this client_obd */ struct list_head cl_lru_list; /** Lock for LRU page list */ diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 4f56a49..575b296 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -183,10 +183,12 @@ static int osc_cached_mb_seq_show(struct seq_file *m, void *v) seq_printf(m, "used_mb: %ld\n" - "busy_cnt: %ld\n", + "busy_cnt: %ld\n" + "reclaim: %llu\n", (atomic_long_read(&cli->cl_lru_in_list) + atomic_long_read(&cli->cl_lru_busy)) >> shift, - atomic_long_read(&cli->cl_lru_busy)); + atomic_long_read(&cli->cl_lru_busy), + cli->cl_lru_reclaim); return 0; } diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 462a3ad..b0f030c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1329,7 +1329,6 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, { struct osc_page *opg = oap2osc_page(oap); struct cl_page *page = oap2cl_page(oap); - struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); enum cl_req_type crt; int srvlock; @@ -1344,13 +1343,6 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, /* Clear opg->ops_transfer_pinned before VM lock is released. */ opg->ops_transfer_pinned = 0; - spin_lock(&obj->oo_seatbelt); - LASSERT(opg->ops_submitter); - LASSERT(!list_empty(&opg->ops_inflight)); - list_del_init(&opg->ops_inflight); - opg->ops_submitter = NULL; - spin_unlock(&obj->oo_seatbelt); - opg->ops_submit_time = 0; srvlock = oap->oap_brw_flags & OBD_BRW_SRVLOCK; @@ -1381,7 +1373,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, #define OSC_DUMP_GRANT(lvl, cli, fmt, args...) do { \ struct client_obd *__tmp = (cli); \ - CDEBUG(lvl, "%s: grant { dirty: %ld/%ld dirty_pages: %ld/%lu " \ + CDEBUG(lvl, "%s: grant { dirty: %lu/%lu dirty_pages: %ld/%lu " \ "dropped: %ld avail: %ld, reserved: %ld, flight: %d }" \ "lru {in list: %ld, left: %ld, waiters: %d }" fmt "\n", \ cli_name(__tmp), \ @@ -2246,14 +2238,9 @@ static int osc_io_unplug0(const struct lu_env *env, struct client_obd *cli, return 0; if (!async) { - /* disable osc_lru_shrink() temporarily to avoid - * potential stack overrun problem. LU-2859 - */ - atomic_inc(&cli->cl_lru_shrinkers); spin_lock(&cli->cl_loi_list_lock); osc_check_rpcs(env, cli); spin_unlock(&cli->cl_loi_list_lock); - atomic_dec(&cli->cl_lru_shrinkers); } else { CDEBUG(D_CACHE, "Queue writeback work for client %p.\n", cli); LASSERT(cli->cl_writeback_work); @@ -2475,7 +2462,6 @@ 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; int rc = 0; LASSERT(oap->oap_magic == OAP_MAGIC); @@ -2483,12 +2469,15 @@ int osc_teardown_async_page(const struct lu_env *env, CDEBUG(D_INFO, "teardown oap %p page %p at index %lu.\n", oap, ops, osc_index(oap2osc(oap))); - osc_object_lock(obj); if (!list_empty(&oap->oap_rpc_item)) { CDEBUG(D_CACHE, "oap %p is not in cache.\n", oap); rc = -EBUSY; } else if (!list_empty(&oap->oap_pending_item)) { + struct osc_extent *ext = NULL; + + osc_object_lock(obj); ext = osc_extent_lookup(obj, osc_index(oap2osc(oap))); + osc_object_unlock(obj); /* only truncated pages are allowed to be taken out. * See osc_extent_truncate() and osc_cache_truncate_start() * for details. @@ -2498,10 +2487,9 @@ int osc_teardown_async_page(const struct lu_env *env, osc_index(oap2osc(oap))); rc = -EBUSY; } + if (ext) + osc_extent_put(env, ext); } - osc_object_unlock(obj); - if (ext) - osc_extent_put(env, ext); return rc; } diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index bf05a2d..cce55a9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -120,16 +120,6 @@ struct osc_object { int oo_contended; unsigned long oo_contention_time; /** - * List of pages in transfer. - */ - struct list_head oo_inflight[CRT_NR]; - /** - * Lock, protecting osc_page::ops_inflight, because a seat-belt is - * locked during take-off and landing. - */ - spinlock_t oo_seatbelt; - - /** * used by the osc to keep track of what objects to build into rpcs. * Protected by client_obd->cli_loi_list_lock. */ @@ -357,15 +347,6 @@ struct osc_page { */ struct list_head ops_lru; /** - * Linkage into a per-osc_object list of pages in flight. For - * debugging. - */ - struct list_head ops_inflight; - /** - * Thread that submitted this page for transfer. For debugging. - */ - struct task_struct *ops_submitter; - /** * Submit time - the time when the page is starting RPC. For debugging. */ unsigned long ops_submit_time; diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index c5b58e9..688783d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -133,7 +133,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, struct list_head *ext_list, int cmd); long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, long target, bool force); -long osc_lru_reclaim(struct client_obd *cli); +long osc_lru_reclaim(struct client_obd *cli, unsigned long npages); unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock); diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 97b012d..439ba64 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -352,7 +352,7 @@ static int osc_io_rw_iter_init(const struct lu_env *env, npages = max_pages; c = atomic_long_read(cli->cl_lru_left); - if (c < npages && osc_lru_reclaim(cli) > 0) + if (c < npages && osc_lru_reclaim(cli, npages) > 0) c = atomic_long_read(cli->cl_lru_left); while (c >= npages) { if (c == atomic_long_cmpxchg(cli->cl_lru_left, c, c - npages)) { @@ -361,6 +361,17 @@ static int osc_io_rw_iter_init(const struct lu_env *env, } c = atomic_long_read(cli->cl_lru_left); } + if (atomic_long_read(cli->cl_lru_left) < max_pages) { + /* + * If there aren't enough pages in the per-OSC LRU then + * wake up the LRU thread to try and clear out space, so + * we don't block if pages are being dirtied quickly. + */ + CDEBUG(D_CACHE, "%s: queue LRU, left: %lu/%ld.\n", + cli_name(cli), atomic_long_read(cli->cl_lru_left), + max_pages); + (void)ptlrpcd_queue_work(cli->cl_lru_work); + } return 0; } diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index 3592796..e0c3324 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -71,13 +71,8 @@ static int osc_object_init(const struct lu_env *env, struct lu_object *obj, { struct osc_object *osc = lu2osc(obj); const struct cl_object_conf *cconf = lu2cl_conf(conf); - int i; osc->oo_oinfo = cconf->u.coc_oinfo; - spin_lock_init(&osc->oo_seatbelt); - for (i = 0; i < CRT_NR; ++i) - INIT_LIST_HEAD(&osc->oo_inflight[i]); - INIT_LIST_HEAD(&osc->oo_ready_item); INIT_LIST_HEAD(&osc->oo_hp_ready_item); INIT_LIST_HEAD(&osc->oo_write_item); @@ -103,10 +98,6 @@ static int osc_object_init(const struct lu_env *env, struct lu_object *obj, static void osc_object_free(const struct lu_env *env, struct lu_object *obj) { struct osc_object *osc = lu2osc(obj); - int i; - - for (i = 0; i < CRT_NR; ++i) - LASSERT(list_empty(&osc->oo_inflight[i])); LASSERT(list_empty(&osc->oo_ready_item)); LASSERT(list_empty(&osc->oo_hp_ready_item)); diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 54c483c..a80a847 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -37,6 +37,7 @@ #define DEBUG_SUBSYSTEM S_OSC +#include #include "osc_cl_internal.h" static void osc_lru_del(struct client_obd *cli, struct osc_page *opg); @@ -86,11 +87,6 @@ static void osc_page_transfer_add(const struct lu_env *env, struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); osc_lru_use(osc_cli(obj), opg); - - spin_lock(&obj->oo_seatbelt); - list_add(&opg->ops_inflight, &obj->oo_inflight[crt]); - opg->ops_submitter = current; - spin_unlock(&obj->oo_seatbelt); } int osc_page_cache_add(const struct lu_env *env, @@ -140,7 +136,7 @@ static int osc_page_print(const struct lu_env *env, 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 %lu: 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", + return (*printer)(env, cookie, LUSTRE_OSC_NAME "-page@%p %lu: 1< %#x %d %u %s %s > 2< %llu %u %u %#x %#x | %p %p %p > 3< %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, osc_index(opg), /* 1 */ oap->oap_magic, oap->oap_cmd, @@ -152,8 +148,7 @@ static int osc_page_print(const struct lu_env *env, oap->oap_async_flags, oap->oap_brw_flags, oap->oap_request, oap->oap_cli, obj, /* 3 */ - osc_list(&opg->ops_inflight), - opg->ops_submitter, opg->ops_transfer_pinned, + opg->ops_transfer_pinned, osc_submit_duration(opg), opg->ops_srvlock, /* 4 */ cli->cl_r_in_flight, cli->cl_w_in_flight, @@ -192,14 +187,6 @@ static void osc_page_delete(const struct lu_env *env, LASSERT(0); } - spin_lock(&obj->oo_seatbelt); - if (opg->ops_submitter) { - LASSERT(!list_empty(&opg->ops_inflight)); - list_del_init(&opg->ops_inflight); - opg->ops_submitter = NULL; - } - spin_unlock(&obj->oo_seatbelt); - osc_lru_del(osc_cli(obj), opg); if (slice->cpl_page->cp_type == CPT_CACHEABLE) { @@ -282,10 +269,6 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj, cl_page_slice_add(page, &opg->ops_cl, obj, index, &osc_page_ops); } - /* ops_inflight and ops_lru are the same field, but it doesn't - * hurt to initialize it twice :-) - */ - INIT_LIST_HEAD(&opg->ops_inflight); INIT_LIST_HEAD(&opg->ops_lru); /* reserve an LRU space for this page */ @@ -349,8 +332,18 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, * LRU pages are freed in batch mode. OSC should at least free this * number of pages to avoid running out of LRU slots. */ -static const int lru_shrink_min = 2 << (20 - PAGE_SHIFT); /* 2M */ -static const int lru_shrink_max = 8 << (20 - PAGE_SHIFT); /* 8M */ +static inline int lru_shrink_min(struct client_obd *cli) +{ + return cli->cl_max_pages_per_rpc * 2; +} + +/** + * free this number at most otherwise it will take too long time to finish. + */ +static inline int lru_shrink_max(struct client_obd *cli) +{ + return cli->cl_max_pages_per_rpc * cli->cl_max_rpcs_in_flight; +} /** * Check if we can free LRU slots from this OSC. If there exists LRU waiters, @@ -370,13 +363,20 @@ static int osc_cache_too_much(struct client_obd *cli) /* if it's going to run out LRU slots, we should free some, but not * too much to maintain fairness among OSCs. */ - if (atomic_long_read(cli->cl_lru_left) < cache->ccc_lru_max >> 4) { + if (atomic_long_read(cli->cl_lru_left) < cache->ccc_lru_max >> 2) { if (pages >= budget) - return lru_shrink_max; + return lru_shrink_max(cli); else if (pages >= budget / 2) - return lru_shrink_min; - } else if (pages >= budget * 2) { - return lru_shrink_min; + return lru_shrink_min(cli); + } else { + time64_t duration = ktime_get_real_seconds(); + + /* knock out pages by duration of no IO activity */ + duration -= cli->cl_lru_last_used; + duration >>= 6; /* approximately 1 minute */ + if (duration > 0 && + pages >= div64_s64((s64)budget, duration)) + return lru_shrink_min(cli); } return 0; } @@ -384,11 +384,21 @@ static int osc_cache_too_much(struct client_obd *cli) int lru_queue_work(const struct lu_env *env, void *data) { struct client_obd *cli = data; + int count; CDEBUG(D_CACHE, "%s: run LRU work for client obd\n", cli_name(cli)); - if (osc_cache_too_much(cli)) - osc_lru_shrink(env, cli, lru_shrink_max, true); + count = osc_cache_too_much(cli); + if (count > 0) { + int rc = osc_lru_shrink(env, cli, count, false); + + CDEBUG(D_CACHE, "%s: shrank %d/%d pages from client obd\n", + cli_name(cli), rc, count); + if (rc >= count) { + CDEBUG(D_CACHE, "%s: queue again\n", cli_name(cli)); + ptlrpcd_queue_work(cli->cl_lru_work); + } + } return 0; } @@ -415,10 +425,10 @@ void osc_lru_add_batch(struct client_obd *cli, struct list_head *plist) list_splice_tail(&lru, &cli->cl_lru_list); atomic_long_sub(npages, &cli->cl_lru_busy); atomic_long_add(npages, &cli->cl_lru_in_list); + cli->cl_lru_last_used = ktime_get_real_seconds(); spin_unlock(&cli->cl_lru_list_lock); - /* XXX: May set force to be true for better performance */ - if (osc_cache_too_much(cli)) + if (waitqueue_active(&osc_lru_waitq)) (void)ptlrpcd_queue_work(cli->cl_lru_work); } } @@ -451,8 +461,10 @@ static void osc_lru_del(struct client_obd *cli, struct osc_page *opg) * this osc occupies too many LRU pages and kernel is * stealing one of them. */ - if (!memory_pressure_get()) + if (osc_cache_too_much(cli)) { + CDEBUG(D_CACHE, "%s: queue LRU workn", cli_name(cli)); (void)ptlrpcd_queue_work(cli->cl_lru_work); + } wake_up(&osc_lru_waitq); } else { LASSERT(list_empty(&opg->ops_lru)); @@ -484,6 +496,7 @@ static void discard_pagevec(const struct lu_env *env, struct cl_io *io, struct cl_page *page = pvec[i]; LASSERT(cl_page_is_owned(page, io)); + cl_page_delete(env, page); cl_page_discard(env, io, page); cl_page_disown(env, io, page); cl_page_put(env, page); @@ -534,6 +547,8 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, if (atomic_long_read(&cli->cl_lru_in_list) == 0 || target <= 0) return 0; + CDEBUG(D_CACHE, "%s: shrinkers: %d, force: %d\n", + cli_name(cli), atomic_read(&cli->cl_lru_shrinkers), force); if (!force) { if (atomic_read(&cli->cl_lru_shrinkers) > 0) return -EBUSY; @@ -550,11 +565,16 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, io = &osc_env_info(env)->oti_io; spin_lock(&cli->cl_lru_list_lock); + if (force) + cli->cl_lru_reclaim++; maxscan = min(target << 1, atomic_long_read(&cli->cl_lru_in_list)); list_for_each_entry_safe(opg, temp, &cli->cl_lru_list, ops_lru) { struct cl_page *page; bool will_free = false; + if (!force && atomic_read(&cli->cl_lru_shrinkers) > 1) + break; + if (--maxscan < 0) break; @@ -650,7 +670,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, * LRU pages in batch. Therefore, the actual number is adjusted at least * max_pages_per_rpc. */ -long osc_lru_reclaim(struct client_obd *cli) +long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) { struct lu_env *env; struct cl_client_cache *cache = cli->cl_cache; @@ -664,19 +684,23 @@ long osc_lru_reclaim(struct client_obd *cli) if (IS_ERR(env)) return 0; - rc = osc_lru_shrink(env, cli, osc_cache_too_much(cli), false); - if (rc != 0) { - if (rc == -EBUSY) - rc = 0; - - CDEBUG(D_CACHE, "%s: Free %ld pages from own LRU: %p.\n", - cli->cl_import->imp_obd->obd_name, rc, cli); + npages = max_t(int, npages, cli->cl_max_pages_per_rpc); + CDEBUG(D_CACHE, "%s: start to reclaim %ld pages from LRU\n", + cli_name(cli), npages); + rc = osc_lru_shrink(env, cli, npages, true); + if (rc >= npages) { + CDEBUG(D_CACHE, "%s: reclaimed %ld/%ld pages from LRU\n", + cli_name(cli), rc, npages); + if (osc_cache_too_much(cli) > 0) + ptlrpcd_queue_work(cli->cl_lru_work); goto out; + } else if (rc > 0) { + npages -= rc; } - CDEBUG(D_CACHE, "%s: cli %p no free slots, pages: %ld, busy: %ld.\n", + CDEBUG(D_CACHE, "%s: cli %p no free slots, pages: %ld/%ld, want: %ld\n", cli_name(cli), cli, atomic_long_read(&cli->cl_lru_in_list), - atomic_long_read(&cli->cl_lru_busy)); + atomic_long_read(&cli->cl_lru_busy), npages); /* Reclaim LRU slots from other client_obd as it can't free enough * from its own. This should rarely happen. @@ -701,11 +725,12 @@ long osc_lru_reclaim(struct client_obd *cli) if (osc_cache_too_much(cli) > 0) { spin_unlock(&cache->ccc_lru_lock); - rc = osc_lru_shrink(env, cli, osc_cache_too_much(cli), - true); + rc = osc_lru_shrink(env, cli, npages, true); spin_lock(&cache->ccc_lru_lock); - if (rc != 0) + if (rc >= npages) break; + if (rc > 0) + npages -= rc; } } spin_unlock(&cache->ccc_lru_lock); @@ -743,7 +768,7 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, LASSERT(atomic_long_read(cli->cl_lru_left) >= 0); while (!atomic_long_add_unless(cli->cl_lru_left, -1, 0)) { /* run out of LRU spaces, try to drop some by itself */ - rc = osc_lru_reclaim(cli); + rc = osc_lru_reclaim(cli, 1); if (rc < 0) break; if (rc > 0) @@ -846,7 +871,7 @@ void osc_dec_unstable_pages(struct ptlrpc_request *req) if (!unstable_count) wake_up_all(&cli->cl_cache->ccc_unstable_waitq); - if (osc_cache_too_much(cli)) + if (waitqueue_active(&osc_lru_waitq)) (void)ptlrpcd_queue_work(cli->cl_lru_work); } diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 6618379..5197768 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -583,12 +583,12 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, oa->o_undirty = 0; } else if (unlikely(atomic_long_read(&obd_dirty_pages) - atomic_long_read(&obd_dirty_transit_pages) > - (obd_max_dirty_pages + 1))) { + (long)(obd_max_dirty_pages + 1))) { /* The atomic_read() allowing the atomic_inc() are * not covered by a lock thus they may safely race and trip * this CERROR() unless we add in a small fudge factor (+1). */ - CERROR("%s: dirty %ld + %ld > system dirty_max %lu\n", + CERROR("%s: dirty %ld + %ld > system dirty_max %ld\n", cli_name(cli), atomic_long_read(&obd_dirty_pages), atomic_long_read(&obd_dirty_transit_pages), obd_max_dirty_pages); -- 1.7.1 From jsimmons at infradead.org Thu Dec 1 22:35:29 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 1 Dec 2016 17:35:29 -0500 Subject: [lustre-devel] [PATCH 0/3] staging: lustre: osc: performance tuning for LRU Message-ID: <1480631732-6880-1-git-send-email-jsimmons@infradead.org> Early launch page LRU work in osc_io_rw_iter_init(); Change the page LRU shrinking policy by OSC attributes; Delete the contented lock osc_object::oo_seatbelt Original patch has been broken into 3 parts for upstream merger. Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5108 Reviewed-on: http://review.whamcloud.com/10458 Reviewed-by: Bobi Jam Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin Signed-off-by: James Simmons Jinshan Xiong (3): staging: lustre: osc: add and fixup comments for LRU handling staging: lustre: osc: create cli_name to get obd name staging: lustre: osc: Performance tune for LRU drivers/staging/lustre/lustre/include/obd.h | 35 ++++- drivers/staging/lustre/lustre/osc/lproc_osc.c | 6 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 34 ++--- .../staging/lustre/lustre/osc/osc_cl_internal.h | 19 --- drivers/staging/lustre/lustre/osc/osc_internal.h | 7 +- drivers/staging/lustre/lustre/osc/osc_io.c | 13 ++- drivers/staging/lustre/lustre/osc/osc_object.c | 9 -- drivers/staging/lustre/lustre/osc/osc_page.c | 148 ++++++++++++-------- drivers/staging/lustre/lustre/osc/osc_quota.c | 4 +- drivers/staging/lustre/lustre/osc/osc_request.c | 17 +-- 10 files changed, 162 insertions(+), 130 deletions(-) From jsimmons at infradead.org Thu Dec 1 22:35:31 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 1 Dec 2016 17:35:31 -0500 Subject: [lustre-devel] [PATCH 2/3] staging: lustre: osc: create cli_name to get obd name In-Reply-To: <1480631732-6880-1-git-send-email-jsimmons@infradead.org> References: <1480631732-6880-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480631732-6880-3-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong Create the inline function cli_name() to get the name of the OSC device. Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5108 Reviewed-on: http://review.whamcloud.com/10458 Reviewed-by: Bobi Jam Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/osc_cache.c | 8 ++++---- drivers/staging/lustre/lustre/osc/osc_internal.h | 5 +++++ drivers/staging/lustre/lustre/osc/osc_page.c | 12 +++++------- drivers/staging/lustre/lustre/osc/osc_quota.c | 4 ++-- drivers/staging/lustre/lustre/osc/osc_request.c | 13 +++++-------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 0b5f4b2..462a3ad 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -961,7 +961,7 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, if (rc == -ETIMEDOUT) { OSC_EXTENT_DUMP(D_ERROR, ext, "%s: wait ext to %u timedout, recovery in progress?\n", - osc_export(obj)->exp_obd->obd_name, state); + cli_name(osc_cli(obj)), state); lwi = LWI_INTR(NULL, NULL); rc = l_wait_event(ext->oe_waitq, extent_wait_cb(ext, state), @@ -1384,7 +1384,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, CDEBUG(lvl, "%s: grant { dirty: %ld/%ld dirty_pages: %ld/%lu " \ "dropped: %ld avail: %ld, reserved: %ld, flight: %d }" \ "lru {in list: %ld, left: %ld, waiters: %d }" fmt "\n", \ - __tmp->cl_import->imp_obd->obd_name, \ + cli_name(__tmp), \ __tmp->cl_dirty_pages, __tmp->cl_dirty_max_pages, \ atomic_long_read(&obd_dirty_pages), obd_max_dirty_pages, \ __tmp->cl_lost_grant, __tmp->cl_avail_grant, \ @@ -1622,7 +1622,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, osc_io_unplug_async(env, cli, NULL); CDEBUG(D_CACHE, "%s: sleeping for cache space @ %p for %p\n", - cli->cl_import->imp_obd->obd_name, &ocw, oap); + cli_name(cli), &ocw, oap); rc = l_wait_event(ocw.ocw_waitq, ocw_granted(cli, &ocw), &lwi); @@ -1666,7 +1666,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, break; default: CDEBUG(D_CACHE, "%s: event for cache space @ %p never arrived due to %d, fall back to sync i/o\n", - cli->cl_import->imp_obd->obd_name, &ocw, rc); + cli_name(cli), &ocw, rc); break; } out: diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 981b7e1..c5b58e9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -155,6 +155,11 @@ static inline unsigned long rpcs_in_flight(struct client_obd *cli) return cli->cl_r_in_flight + cli->cl_w_in_flight; } +static inline char *cli_name(struct client_obd *cli) +{ + return cli->cl_import->imp_obd->obd_name; +} + struct osc_device { struct cl_device od_cl; struct obd_export *od_exp; diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 2cdc30a..54c483c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -385,7 +385,7 @@ int lru_queue_work(const struct lu_env *env, void *data) { struct client_obd *cli = data; - CDEBUG(D_CACHE, "Run LRU work for client obd %p.\n", cli); + CDEBUG(D_CACHE, "%s: run LRU work for client obd\n", cli_name(cli)); if (osc_cache_too_much(cli)) osc_lru_shrink(env, cli, lru_shrink_max, true); @@ -675,8 +675,7 @@ long osc_lru_reclaim(struct client_obd *cli) } CDEBUG(D_CACHE, "%s: cli %p no free slots, pages: %ld, busy: %ld.\n", - cli->cl_import->imp_obd->obd_name, cli, - atomic_long_read(&cli->cl_lru_in_list), + cli_name(cli), cli, atomic_long_read(&cli->cl_lru_in_list), atomic_long_read(&cli->cl_lru_busy)); /* Reclaim LRU slots from other client_obd as it can't free enough @@ -694,7 +693,7 @@ long osc_lru_reclaim(struct client_obd *cli) cl_lru_osc); CDEBUG(D_CACHE, "%s: cli %p LRU pages: %ld, busy: %ld.\n", - cli->cl_import->imp_obd->obd_name, cli, + cli_name(cli), cli, atomic_long_read(&cli->cl_lru_in_list), atomic_long_read(&cli->cl_lru_busy)); @@ -714,7 +713,7 @@ long osc_lru_reclaim(struct client_obd *cli) out: cl_env_put(env, &refcheck); CDEBUG(D_CACHE, "%s: cli %p freed %ld pages.\n", - cli->cl_import->imp_obd->obd_name, cli, rc); + cli_name(cli), cli, rc); return rc; } @@ -903,8 +902,7 @@ bool osc_over_unstable_soft_limit(struct client_obd *cli) CDEBUG(D_CACHE, "%s: cli: %p unstable pages: %lu, osc unstable pages: %lu\n", - cli->cl_import->imp_obd->obd_name, cli, - unstable_nr, osc_unstable_count); + cli_name(cli), cli, unstable_nr, osc_unstable_count); /* * If the LRU slots are in shortage - 25% remaining AND this OSC diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index acdd91a..4bb3b45 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -106,7 +106,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], } CDEBUG(D_QUOTA, "%s: setdq to insert for %s %d (%d)\n", - cli->cl_import->imp_obd->obd_name, + cli_name(cli), type == USRQUOTA ? "user" : "group", qid[type], rc); } else { @@ -122,7 +122,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], 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, + cli_name(cli), type == USRQUOTA ? "user" : "group", qid[type], oqi); } diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 4d4d3eb..6618379 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -589,8 +589,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, * this CERROR() unless we add in a small fudge factor (+1). */ CERROR("%s: dirty %ld + %ld > system dirty_max %lu\n", - cli->cl_import->imp_obd->obd_name, - atomic_long_read(&obd_dirty_pages), + cli_name(cli), atomic_long_read(&obd_dirty_pages), atomic_long_read(&obd_dirty_transit_pages), obd_max_dirty_pages); oa->o_undirty = 0; @@ -785,12 +784,10 @@ static int osc_add_shrink_grant(struct client_obd *client) osc_grant_shrink_grant_cb, NULL, &client->cl_grant_shrink_list); if (rc) { - CERROR("add grant client %s error %d\n", - client->cl_import->imp_obd->obd_name, rc); + CERROR("add grant client %s error %d\n", cli_name(client), rc); return rc; } - CDEBUG(D_CACHE, "add grant client %s\n", - client->cl_import->imp_obd->obd_name); + CDEBUG(D_CACHE, "add grant client %s\n", cli_name(client)); osc_update_next_shrink(client); return 0; } @@ -824,8 +821,8 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd) spin_unlock(&cli->cl_loi_list_lock); CDEBUG(D_CACHE, "%s, setting cl_avail_grant: %ld cl_lost_grant: %ld chunk bits: %d\n", - cli->cl_import->imp_obd->obd_name, - cli->cl_avail_grant, cli->cl_lost_grant, cli->cl_chunkbits); + cli_name(cli), cli->cl_avail_grant, cli->cl_lost_grant, + cli->cl_chunkbits); if (ocd->ocd_connect_flags & OBD_CONNECT_GRANT_SHRINK && list_empty(&cli->cl_grant_shrink_list)) -- 1.7.1 From jsimmons at infradead.org Thu Dec 1 22:35:30 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 1 Dec 2016 17:35:30 -0500 Subject: [lustre-devel] [PATCH 1/3] staging: lustre: osc: add and fixup comments for LRU handling In-Reply-To: <1480631732-6880-1-git-send-email-jsimmons@infradead.org> References: <1480631732-6880-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480631732-6880-2-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong Add new information about the fields in struct client_obd. Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5108 Reviewed-on: http://review.whamcloud.com/10458 Reviewed-by: Bobi Jam Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd.h | 27 ++++++++++++++++++++++--- drivers/staging/lustre/lustre/osc/osc_page.c | 17 +++++++++++---- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index d4d2ffa..6d6e479 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -247,15 +247,34 @@ struct client_obd { struct obd_histogram cl_read_offset_hist; struct obd_histogram cl_write_offset_hist; - /* lru for osc caching pages */ + /* LRU for osc caching pages */ struct cl_client_cache *cl_cache; - struct list_head cl_lru_osc; /* member of cl_cache->ccc_lru */ + /** member of cl_cache->ccc_lru */ + struct list_head cl_lru_osc; + /** # of available LRU slots left in the per-OSC cache. + * Available LRU slots are shared by all OSCs of the same file system, + * therefore this is a pointer to cl_client_cache::ccc_lru_left. + */ atomic_long_t *cl_lru_left; + /** # of busy LRU pages. A page is considered busy if it's in writeback + * queue, or in transfer. Busy pages can't be discarded so they are not + * in LRU cache. + */ atomic_long_t cl_lru_busy; + /** # of LRU pages in the cache for this client_obd */ atomic_long_t cl_lru_in_list; + /** # of threads are shrinking LRU cache. To avoid contention, it's not + * allowed to have multiple threads shrinking LRU cache. + */ atomic_t cl_lru_shrinkers; - struct list_head cl_lru_list; /* lru page list */ - spinlock_t cl_lru_list_lock; /* page list protector */ + /** List of LRU pages for this client_obd */ + struct list_head cl_lru_list; + /** Lock for LRU page list */ + spinlock_t cl_lru_list_lock; + /** # of unstable pages in this client_obd. + * An unstable page is a page state that WRITE RPC has finished but + * the transaction has NOT yet committed. + */ atomic_long_t cl_unstable_count; /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */ diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 7a1f102..2cdc30a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -343,16 +343,17 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, * OSC to free slots voluntarily to maintain a reasonable number of free slots * at any time. */ - static DECLARE_WAIT_QUEUE_HEAD(osc_lru_waitq); -/* LRU pages are freed in batch mode. OSC should at least free this - * number of pages to avoid running out of LRU budget, and.. + +/** + * LRU pages are freed in batch mode. OSC should at least free this + * number of pages to avoid running out of LRU slots. */ static const int lru_shrink_min = 2 << (20 - PAGE_SHIFT); /* 2M */ -/* free this number at most otherwise it will take too long time to finish. */ static const int lru_shrink_max = 8 << (20 - PAGE_SHIFT); /* 8M */ -/* Check if we can free LRU slots from this OSC. If there exists LRU waiters, +/** + * Check if we can free LRU slots from this OSC. If there exists LRU waiters, * we should free slots aggressively. In this way, slots are freed in a steady * step to maintain fairness among OSCs. * @@ -643,6 +644,12 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, return count > 0 ? count : rc; } +/** + * Reclaim LRU pages by an IO thread. The caller wants to reclaim at least + * \@npages of LRU slots. For performance consideration, it's better to drop + * LRU pages in batch. Therefore, the actual number is adjusted at least + * max_pages_per_rpc. + */ long osc_lru_reclaim(struct client_obd *cli) { struct lu_env *env; -- 1.7.1 From gregkh at linuxfoundation.org Fri Dec 2 10:42:44 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Fri, 2 Dec 2016 11:42:44 +0100 Subject: [lustre-devel] [PATCH 21/22 v2] staging/lustre/libcfs: Convert to hotplug state machine In-Reply-To: <20161202101825.mcsbw4nr4slymcvl@linutronix.de> References: <20161126231350.10321-1-bigeasy@linutronix.de> <20161126231350.10321-22-bigeasy@linutronix.de> <20161202101825.mcsbw4nr4slymcvl@linutronix.de> Message-ID: <20161202104244.GB8736@kroah.com> On Fri, Dec 02, 2016 at 11:18:25AM +0100, Sebastian Andrzej Siewior wrote: > From: Anna-Maria Gleixner > > Install the callbacks via the state machine. > Cc: Oleg Drokin > Cc: Andreas Dilger > Cc: James Simmons > Cc: Greg Kroah-Hartman > Cc: lustre-devel at lists.lustre.org > Cc: devel at driverdev.osuosl.org > Signed-off-by: Anna-Maria Gleixner > [bigeasy: rebase to linux-next] > Signed-off-by: Sebastian Andrzej Siewior > --- > v1…v2: rebase to linux-next > > Side note: Is there a reason the handle the down state very late at > CPU_DEAD time and use the counterpart of the online callback (the old > CPU_DOWN_PREPARE state). You need a blank line before the cc: lines in your changelog please... thanks, greg k-h From lambert.quentin at gmail.com Fri Dec 2 17:33:32 2016 From: lambert.quentin at gmail.com (Quentin Lambert) Date: Fri, 2 Dec 2016 18:33:32 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space Message-ID: <20161202173332.5100-1-lambert.quentin@gmail.com> lnet_ipif_enumerate was assigning a pointer from kernel space to user space. This patch uses copy_to_user to properly do that assignment. Signed-off-by: Quentin Lambert --- shouldn't we be using ifc_req instead of ifc_buf? drivers/staging/lustre/lnet/lnet/lib-socket.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -181,7 +181,13 @@ lnet_ipif_enumerate(char ***namesp) goto out0; } - ifc.ifc_buf = (char *)ifr; + rc = copy_to_user(ifc.ifc_buf, (char *)ifr, + nalloc * sizeof(*ifr)); + if (rc) { + rc = -ENOMEM; + goto out1; + } + ifc.ifc_len = nalloc * sizeof(*ifr); rc = lnet_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc); From jsimmons at infradead.org Fri Dec 2 19:40:46 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 14:40:46 -0500 Subject: [lustre-devel] [PATCH 2/6] staging: lustre: headers: sort headers affected by swab move In-Reply-To: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480707650-24089-3-git-send-email-jsimmons@infradead.org> From: Ben Evans It was found if you sort the headers alphabetically that it reduced patch conflicts. This patch sorts the headers alphabetically and also place linux header first, then uapi header and finally the lustre kernel headers. Signed-off-by: Ben Evans Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6401 Reviewed-on: http://review.whamcloud.com/16339 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lov/lov_obd.c | 17 +++++++++-------- drivers/staging/lustre/lustre/lov/lov_pack.c | 6 ++++-- drivers/staging/lustre/lustre/mdc/mdc_request.c | 11 ++++++----- drivers/staging/lustre/lustre/mgc/mgc_request.c | 7 ++++--- drivers/staging/lustre/lustre/obdclass/llog.c | 2 +- .../staging/lustre/lustre/obdclass/obd_config.c | 6 ++++-- drivers/staging/lustre/lustre/ptlrpc/layout.c | 14 ++++++-------- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 7 ++++--- 8 files changed, 38 insertions(+), 32 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index b236e93..63b0645 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -40,19 +40,20 @@ #define DEBUG_SUBSYSTEM S_LOV #include "../../include/linux/libcfs/libcfs.h" -#include "../include/obd_support.h" -#include "../include/lustre/lustre_ioctl.h" -#include "../include/lustre_lib.h" -#include "../include/lustre_net.h" #include "../include/lustre/lustre_idl.h" +#include "../include/lustre/lustre_ioctl.h" + +#include "../include/cl_object.h" #include "../include/lustre_dlm.h" +#include "../include/lustre_fid.h" +#include "../include/lustre_lib.h" #include "../include/lustre_mds.h" -#include "../include/obd_class.h" +#include "../include/lustre_net.h" +#include "../include/lustre_param.h" #include "../include/lustre_swab.h" #include "../include/lprocfs_status.h" -#include "../include/lustre_param.h" -#include "../include/cl_object.h" -#include "../include/lustre_fid.h" +#include "../include/obd_class.h" +#include "../include/obd_support.h" #include "lov_internal.h" diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 561b246..6c93d18 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -38,15 +38,17 @@ #define DEBUG_SUBSYSTEM S_LOV +#include "../include/lustre/lustre_idl.h" +#include "../include/lustre/lustre_user.h" + #include "../include/lustre_net.h" #include "../include/lustre_swab.h" #include "../include/obd.h" #include "../include/obd_class.h" #include "../include/obd_support.h" -#include "../include/lustre/lustre_user.h" -#include "lov_internal.h" #include "lov_cl_internal.h" +#include "lov_internal.h" void lov_dump_lmm_common(int level, void *lmmp) { diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 087c2cf..2cfd913 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -38,17 +38,18 @@ # include # include +#include "../include/cl_object.h" #include "../include/llog_swab.h" +#include "../include/lprocfs_status.h" #include "../include/lustre_acl.h" +#include "../include/lustre_fid.h" #include "../include/lustre/lustre_ioctl.h" -#include "../include/obd_class.h" +#include "../include/lustre_kernelcomm.h" #include "../include/lustre_lmv.h" -#include "../include/lustre_fid.h" -#include "../include/lprocfs_status.h" -#include "../include/lustre_param.h" #include "../include/lustre_log.h" -#include "../include/lustre_kernelcomm.h" +#include "../include/lustre_param.h" #include "../include/lustre_swab.h" +#include "../include/obd_class.h" #include "mdc_internal.h" diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index b5370f6..6894d4c 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -38,12 +38,13 @@ #define D_MGC D_CONFIG /*|D_WARNING*/ #include -#include "../include/obd_class.h" -#include "../include/lustre_dlm.h" + #include "../include/lprocfs_status.h" -#include "../include/lustre_log.h" +#include "../include/lustre_dlm.h" #include "../include/lustre_disk.h" +#include "../include/lustre_log.h" #include "../include/lustre_swab.h" +#include "../include/obd_class.h" #include "mgc_internal.h" diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 073abe3..1f6609e 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -44,8 +44,8 @@ #define DEBUG_SUBSYSTEM S_LOG #include "../include/llog_swab.h" -#include "../include/obd_class.h" #include "../include/lustre_log.h" +#include "../include/obd_class.h" #include "llog_internal.h" /* diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index ea68b6d..0a55d79 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -35,13 +35,15 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include "../include/obd_class.h" + #include + #include "../include/lustre/lustre_ioctl.h" #include "../include/llog_swab.h" -#include "../include/lustre_log.h" #include "../include/lprocfs_status.h" +#include "../include/lustre_log.h" #include "../include/lustre_param.h" +#include "../include/obd_class.h" #include "llog_internal.h" diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index eba7098..cc95c09 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -48,23 +48,21 @@ #include -/* LUSTRE_VERSION_CODE */ -#include "../include/lustre_ver.h" - -#include "../include/obd_support.h" -/* lustre_swab_mdt_body */ #include "../include/lustre/lustre_idl.h" -/* obd2cli_tgt() (required by DEBUG_REQ()) */ + +#include "../include/llog_swab.h" +#include "../include/lustre_debug.h" +#include "../include/lustre_swab.h" +#include "../include/lustre_ver.h" #include "../include/obd.h" +#include "../include/obd_support.h" /* __REQ_LAYOUT_USER__ */ #endif -#include "../include/llog_swab.h" /* struct ptlrpc_request, lustre_msg* */ #include "../include/lustre_req_layout.h" #include "../include/lustre_acl.h" #include "../include/lustre_debug.h" -#include "../include/lustre_swab.h" /* * RQFs (see below) refer to two struct req_msg_field arrays describing the diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 1178caa..13f00b7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -42,13 +42,14 @@ #include "../../include/linux/libcfs/libcfs.h" +#include "../include/lustre/ll_fiemap.h" + #include "../include/llog_swab.h" -#include "../include/obd_support.h" -#include "../include/obd_class.h" #include "../include/lustre_net.h" #include "../include/lustre_swab.h" #include "../include/obd_cksum.h" -#include "../include/lustre/ll_fiemap.h" +#include "../include/obd_support.h" +#include "../include/obd_class.h" #include "ptlrpc_internal.h" -- 1.7.1 From jsimmons at infradead.org Fri Dec 2 19:40:49 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 14:40:49 -0500 Subject: [lustre-devel] [PATCH 5/6] staging: lustre: headers: Move functions out of lustre_idl.h In-Reply-To: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480707650-24089-6-git-send-email-jsimmons@infradead.org> From: Ben Evans Migrate functions set/get_mrc_cr_flags, ldlm_res_eq ldlm_extent_overlap, ldlm_extent_contain, ldlm_request_bufsize, and alll the PTLRPC dump_* functions out of lustre_idl.h which is a UAPI header to the places in the kernel code they are actually used. Delete unused lmv_mds_md_stripe_count and agent_req_in_final_state. Signed-off-by: Ben Evans Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6401 Reviewed-on: http://review.whamcloud.com/21484 Reviewed-by: Frank Zago Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_idl.h | 73 -------------------- drivers/staging/lustre/lustre/include/lustre_dlm.h | 13 ++++ .../staging/lustre/lustre/include/lustre_swab.h | 6 ++ drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 6 ++ drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 27 +++++++ drivers/staging/lustre/lustre/mdc/mdc_lib.c | 6 ++ 6 files changed, 58 insertions(+), 73 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 52bef77..b0fef6d 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -2126,17 +2126,6 @@ struct mdt_rec_create { __u32 cr_padding_4; /* rr_padding_4 */ }; -static inline void set_mrc_cr_flags(struct mdt_rec_create *mrc, __u64 flags) -{ - mrc->cr_flags_l = (__u32)(flags & 0xFFFFFFFFUll); - mrc->cr_flags_h = (__u32)(flags >> 32); -} - -static inline __u64 get_mrc_cr_flags(struct mdt_rec_create *mrc) -{ - return ((__u64)(mrc->cr_flags_l) | ((__u64)mrc->cr_flags_h << 32)); -} - /* instance of mdt_reint_rec */ struct mdt_rec_link { __u32 lk_opcode; @@ -2399,25 +2388,6 @@ static inline int lmv_mds_md_stripe_count_get(const union lmv_mds_md *lmm) } } -static inline int lmv_mds_md_stripe_count_set(union lmv_mds_md *lmm, - unsigned int stripe_count) -{ - int rc = 0; - - switch (le32_to_cpu(lmm->lmv_magic)) { - case LMV_MAGIC_V1: - lmm->lmv_md_v1.lmv_stripe_count = cpu_to_le32(stripe_count); - break; - case LMV_USER_MAGIC: - lmm->lmv_user_md.lum_stripe_count = cpu_to_le32(stripe_count); - break; - default: - rc = -EINVAL; - break; - } - return rc; -} - enum fld_rpc_opc { FLD_QUERY = 900, FLD_READ = 901, @@ -2498,12 +2468,6 @@ struct ldlm_res_id { #define PLDLMRES(res) (res)->lr_name.name[0], (res)->lr_name.name[1], \ (res)->lr_name.name[2], (res)->lr_name.name[3] -static inline bool ldlm_res_eq(const struct ldlm_res_id *res0, - const struct ldlm_res_id *res1) -{ - return !memcmp(res0, res1, sizeof(*res0)); -} - /* lock types */ enum ldlm_mode { LCK_MINMODE = 0, @@ -2536,19 +2500,6 @@ struct ldlm_extent { __u64 gid; }; -static inline int ldlm_extent_overlap(const struct ldlm_extent *ex1, - const struct ldlm_extent *ex2) -{ - return (ex1->start <= ex2->end) && (ex2->start <= ex1->end); -} - -/* check if @ex1 contains @ex2 */ -static inline int ldlm_extent_contain(const struct ldlm_extent *ex1, - const struct ldlm_extent *ex2) -{ - return (ex1->start <= ex2->start) && (ex1->end >= ex2->end); -} - struct ldlm_inodebits { __u64 bits; }; @@ -2623,18 +2574,6 @@ struct ldlm_request { struct lustre_handle lock_handle[LDLM_LOCKREQ_HANDLES]; }; -/* If LDLM_ENQUEUE, 1 slot is already occupied, 1 is available. - * Otherwise, 2 are available. - */ -#define ldlm_request_bufsize(count, type) \ -({ \ - int _avail = LDLM_LOCKREQ_HANDLES; \ - _avail -= (type == LDLM_ENQUEUE ? LDLM_ENQUEUE_CANCEL_OFF : 0); \ - sizeof(struct ldlm_request) + \ - (count > _avail ? count - _avail : 0) * \ - sizeof(struct lustre_handle); \ -}) - struct ldlm_reply { __u32 lock_flags; __u32 lock_padding; /* also fix lustre_swab_ldlm_reply */ @@ -2938,12 +2877,6 @@ enum agent_req_status { } } -static inline bool agent_req_in_final_state(enum agent_req_status ars) -{ - return ((ars == ARS_SUCCEED) || (ars == ARS_FAILED) || - (ars == ARS_CANCELED)); -} - struct llog_agent_req_rec { struct llog_rec_hdr arr_hdr; /**< record header */ __u32 arr_status; /**< status of the request */ @@ -3138,12 +3071,6 @@ struct ll_fiemap_info_key { struct fiemap lfik_fiemap; }; -/* Functions for dumping PTLRPC fields */ -void dump_rniobuf(struct niobuf_remote *rnb); -void dump_ioo(struct obd_ioobj *nb); -void dump_ost_body(struct ost_body *ob); -void dump_rcs(__u32 *rc); - /* security opcodes */ enum sec_cmd { SEC_CTX_INIT = 801, diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index b7e61d0..0d7eb80 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -1339,5 +1339,18 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock *lock); /** @} */ +static inline int ldlm_extent_overlap(const struct ldlm_extent *ex1, + const struct ldlm_extent *ex2) +{ + return ex1->start <= ex2->end && ex2->start <= ex1->end; +} + +/* check if @ex1 contains @ex2 */ +static inline int ldlm_extent_contain(const struct ldlm_extent *ex1, + const struct ldlm_extent *ex2) +{ + return ex1->start <= ex2->start && ex1->end >= ex2->end; +} + #endif /** @} LDLM */ diff --git a/drivers/staging/lustre/lustre/include/lustre_swab.h b/drivers/staging/lustre/lustre/include/lustre_swab.h index 26d01c2..5c1bdc0 100644 --- a/drivers/staging/lustre/lustre/include/lustre_swab.h +++ b/drivers/staging/lustre/lustre/include/lustre_swab.h @@ -99,4 +99,10 @@ void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod, void lustre_swab_close_data(struct close_data *data); void lustre_swab_lmv_user_md(struct lmv_user_md *lum); +/* Functions for dumping PTLRPC fields */ +void dump_rniobuf(struct niobuf_remote *rnb); +void dump_ioo(struct obd_ioobj *nb); +void dump_ost_body(struct ost_body *ob); +void dump_rcs(__u32 *rc); + #endif diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 5c02501..d3a9609 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -334,3 +334,9 @@ void ldlm_flock_policy_wire_to_local(const union ldlm_wire_policy_data *wpolicy, union ldlm_policy_data *lpolicy); void ldlm_flock_policy_local_to_wire(const union ldlm_policy_data *lpolicy, union ldlm_wire_policy_data *wpolicy); + +static inline bool ldlm_res_eq(const struct ldlm_res_id *res0, + const struct ldlm_res_id *res1) +{ + return memcmp(res0, res1, sizeof(*res0)) == 0; +} diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index c1f8693..cd6614b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -83,6 +83,33 @@ struct ldlm_async_args { struct lustre_handle lock_handle; }; +/** + * ldlm_request_bufsize + * + * @count: number of ldlm handles + * @type: ldlm opcode + * + * If opcode=LDLM_ENQUEUE, 1 slot is already occupied, + * LDLM_LOCKREQ_HANDLE -1 slots are available. + * Otherwise, LDLM_LOCKREQ_HANDLE slots are available. + * + * Return: size of the request buffer + */ +int ldlm_request_bufsize(int count, int type) +{ + int avail = LDLM_LOCKREQ_HANDLES; + + if (type == LDLM_ENQUEUE) + avail -= LDLM_ENQUEUE_CANCEL_OFF; + + if (count > avail) + avail = (count - avail) * sizeof(struct lustre_handle); + else + avail = 0; + + return sizeof(struct ldlm_request) + avail; +} + static int ldlm_expired_completion_wait(void *data) { struct lock_wait_data *lwd = data; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index c1990f0..3b2ebbd 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -35,6 +35,12 @@ #include "../include/lustre/lustre_idl.h" #include "mdc_internal.h" +static void set_mrc_cr_flags(struct mdt_rec_create *mrc, u64 flags) +{ + mrc->cr_flags_l = (u32)(flags & 0xFFFFFFFFUll); + mrc->cr_flags_h = (u32)(flags >> 32); +} + static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid) { b->mbo_suppgid = suppgid; -- 1.7.1 From jsimmons at infradead.org Fri Dec 2 19:40:45 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 14:40:45 -0500 Subject: [lustre-devel] [PATCH 1/6] staging: lustre: headers: move swab functions to new header files In-Reply-To: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480707650-24089-2-git-send-email-jsimmons@infradead.org> From: Ben Evans Create headers for pack_generic.c and llog_swab.c Reference only where needed. This separates out the kernel only code from lustre_idl.h that is an UAPI header. Signed-off-by: Ben Evans Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6401 Reviewed-on: http://review.whamcloud.com/16339 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/llog_swab.h | 65 +++++++++++ .../staging/lustre/lustre/include/lprocfs_status.h | 2 + .../lustre/lustre/include/lustre/lustre_idl.h | 115 +------------------- .../lustre/lustre/include/lustre/lustre_user.h | 2 - drivers/staging/lustre/lustre/include/lustre_sec.h | 1 + .../staging/lustre/lustre/include/lustre_swab.h | 102 +++++++++++++++++ drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 1 + drivers/staging/lustre/lustre/llite/dir.c | 2 + drivers/staging/lustre/lustre/llite/file.c | 1 + drivers/staging/lustre/lustre/lov/lov_obd.c | 1 + drivers/staging/lustre/lustre/lov/lov_pack.c | 1 + drivers/staging/lustre/lustre/mdc/mdc_locks.c | 4 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 + drivers/staging/lustre/lustre/mgc/mgc_request.c | 1 + drivers/staging/lustre/lustre/obdclass/llog.c | 1 + drivers/staging/lustre/lustre/obdclass/llog_swab.c | 1 + .../staging/lustre/lustre/obdclass/obd_config.c | 1 + drivers/staging/lustre/lustre/ptlrpc/layout.c | 2 + .../staging/lustre/lustre/ptlrpc/pack_generic.c | 2 + 19 files changed, 190 insertions(+), 117 deletions(-) create mode 100644 drivers/staging/lustre/lustre/include/llog_swab.h create mode 100644 drivers/staging/lustre/lustre/include/lustre_swab.h diff --git a/drivers/staging/lustre/lustre/include/llog_swab.h b/drivers/staging/lustre/lustre/include/llog_swab.h new file mode 100644 index 0000000..fd7ffb1 --- /dev/null +++ b/drivers/staging/lustre/lustre/include/llog_swab.h @@ -0,0 +1,65 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2014, Intel Corporation. + * + * Copyright 2015 Cray Inc, all rights reserved. + * Author: Ben Evans. + * + * We assume all nodes are either little-endian or big-endian, and we + * always send messages in the sender's native format. The receiver + * detects the message format by checking the 'magic' field of the message + * (see lustre_msg_swabbed() below). + * + * Each type has corresponding 'lustre_swab_xxxtypexxx()' routines + * are implemented in ptlrpc/pack_generic.c. These 'swabbers' convert the + * type from "other" endian, in-place in the message buffer. + * + * A swabber takes a single pointer argument. The caller must already have + * verified that the length of the message buffer >= sizeof (type). + * + * For variable length types, a second 'lustre_swab_v_xxxtypexxx()' routine + * may be defined that swabs just the variable part, after the caller has + * verified that the message buffer is large enough. + */ + +#ifndef _LLOG_SWAB_H_ +#define _LLOG_SWAB_H_ + +#include "lustre/lustre_idl.h" +struct lustre_cfg; + +void lustre_swab_lu_fid(struct lu_fid *fid); +void lustre_swab_ost_id(struct ost_id *oid); +void lustre_swab_llogd_body(struct llogd_body *d); +void lustre_swab_llog_hdr(struct llog_log_hdr *h); +void lustre_swab_llogd_conn_body(struct llogd_conn_body *d); +void lustre_swab_llog_rec(struct llog_rec_hdr *rec); +void lustre_swab_lu_seq_range(struct lu_seq_range *range); +void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg); +void lustre_swab_cfg_marker(struct cfg_marker *marker, + int swab, int size); + +#endif diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index cc0713e..d0a32d2 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -43,6 +43,8 @@ #include #include +#include "../../include/linux/libcfs/libcfs.h" +#include "lustre_cfg.h" #include "lustre/lustre_idl.h" struct lprocfs_vars { diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index b9f333b..6831e4d 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -48,8 +48,7 @@ * that the Lustre wire protocol is not influenced by external dependencies. * * The only other acceptable items in this file are VERY SIMPLE accessor - * functions to avoid callers grubbing inside the structures, and the - * prototypes of the swabber functions for each struct. Nothing that + * functions to avoid callers grubbing inside the structures. Nothing that * depends on external functions or definitions should be in here. * * Structs must be properly aligned to put 64-bit values on an 8-byte @@ -64,23 +63,6 @@ * in the code to ensure that new/old clients that see this larger struct * do not fail, otherwise you need to implement protocol compatibility). * - * We assume all nodes are either little-endian or big-endian, and we - * always send messages in the sender's native format. The receiver - * detects the message format by checking the 'magic' field of the message - * (see lustre_msg_swabbed() below). - * - * Each wire type has corresponding 'lustre_swab_xxxtypexxx()' routines, - * implemented either here, inline (trivial implementations) or in - * ptlrpc/pack_generic.c. These 'swabbers' convert the type from "other" - * endian, in-place in the message buffer. - * - * A swabber takes a single pointer argument. The caller must already have - * verified that the length of the message buffer >= sizeof (type). - * - * For variable length types, a second 'lustre_swab_v_xxxtypexxx()' routine - * may be defined that swabs just the variable part, after the caller has - * verified that the message buffer is large enough. - * * @{ */ @@ -679,8 +661,6 @@ static inline ino_t lu_igif_ino(const struct lu_fid *fid) return fid_seq(fid); } -void lustre_swab_ost_id(struct ost_id *oid); - /** * Get inode generation from a igif. * \param fid a igif to get inode generation from. @@ -741,8 +721,6 @@ static inline bool fid_is_sane(const struct lu_fid *fid) fid_seq_is_rsvd(fid_seq(fid))); } -void lustre_swab_lu_fid(struct lu_fid *fid); - static inline bool lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1) { return memcmp(f0, f1, sizeof(*f0)) == 0; @@ -1047,8 +1025,6 @@ struct ptlrpc_body_v2 { __u64 pb_padding64_2; }; -void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); - /* message body offset for lustre_msg_v2 */ /* ptlrpc body offset in all request/reply messages */ #define MSG_PTLRPC_BODY_OFF 0 @@ -1275,8 +1251,6 @@ struct obd_connect_data { * reserve the flag for future use. */ -void lustre_swab_connect(struct obd_connect_data *ocd); - /* * Supported checksum algorithms. Up to 32 checksum types are supported. * (32-bit mask stored in obd_connect_data::ocd_cksum_types) @@ -1475,8 +1449,6 @@ static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi, dst_oi->oi.oi_seq = cpu_to_le64(src_oi->oi.oi_seq); } -/* extern void lustre_swab_lov_mds_md(struct lov_mds_md *llm); */ - #define MAX_MD_SIZE \ (sizeof(struct lov_mds_md) + 4 * sizeof(struct lov_ost_data)) #define MIN_MD_SIZE \ @@ -1639,11 +1611,6 @@ struct hsm_state_set { __u64 hss_clearmask; }; -void lustre_swab_hsm_user_state(struct hsm_user_state *hus); -void lustre_swab_hsm_state_set(struct hsm_state_set *hss); - -void lustre_swab_obd_statfs(struct obd_statfs *os); - /* ost_body.data values for OST_BRW */ #define OBD_BRW_READ 0x01 @@ -1689,8 +1656,6 @@ struct obd_ioobj { #define ioobj_max_brw_set(ioo, num) \ do { (ioo)->ioo_max_brw = ((num) - 1) << IOOBJ_MAX_BRW_BITS; } while (0) -void lustre_swab_obd_ioobj(struct obd_ioobj *ioo); - /* multiple of 8 bytes => can array */ struct niobuf_remote { __u64 rnb_offset; @@ -1698,8 +1663,6 @@ struct niobuf_remote { __u32 rnb_flags; }; -void lustre_swab_niobuf_remote(struct niobuf_remote *nbr); - /* lock value block communicated between the filter and llite */ /* OST_LVB_ERR_INIT is needed because the return code in rc is @@ -1721,8 +1684,6 @@ struct ost_lvb_v1 { __u64 lvb_blocks; }; -void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb); - struct ost_lvb { __u64 lvb_size; __s64 lvb_mtime; @@ -1735,8 +1696,6 @@ struct ost_lvb { __u32 lvb_padding; }; -void lustre_swab_ost_lvb(struct ost_lvb *lvb); - /* * lquota data structures */ @@ -1763,8 +1722,6 @@ struct obd_quotactl { struct obd_dqblk qc_dqblk; }; -void lustre_swab_obd_quotactl(struct obd_quotactl *q); - #define Q_COPY(out, in, member) (out)->member = (in)->member #define QCTL_COPY(out, in) \ @@ -1802,8 +1759,6 @@ struct lquota_lvb { __u64 lvb_pad1; }; -void lustre_swab_lquota_lvb(struct lquota_lvb *lvb); - /* op codes */ enum quota_cmd { QUOTA_DQACQ = 601, @@ -1869,8 +1824,6 @@ enum mdt_reint_cmd { REINT_MAX }; -void lustre_swab_generic_32s(__u32 *val); - /* the disposition of the intent outlines what was executed */ #define DISP_IT_EXECD 0x00000001 #define DISP_LOOKUP_EXECD 0x00000002 @@ -2012,8 +1965,6 @@ struct mdt_body { __u64 mbo_padding_10; }; /* 216 */ -void lustre_swab_mdt_body(struct mdt_body *b); - struct mdt_ioepoch { struct lustre_handle mio_handle; __u64 mio_unused1; /* was ioepoch */ @@ -2021,8 +1972,6 @@ struct mdt_ioepoch { __u32 mio_padding; }; -void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b); - /* permissions for md_perm.mp_perm */ enum { CFS_SETUID_PERM = 0x01, @@ -2058,8 +2007,6 @@ struct mdt_rec_setattr { __u32 sa_padding_5; }; -void lustre_swab_mdt_rec_setattr(struct mdt_rec_setattr *sa); - /* * Attribute flags used in mdt_rec_setattr::sa_valid. * The kernel's #defines for ATTR_* should not be used over the network @@ -2334,8 +2281,6 @@ struct mdt_rec_reint { __u32 rr_padding_4; /* also fix lustre_swab_mdt_rec_reint */ }; -void lustre_swab_mdt_rec_reint(struct mdt_rec_reint *rr); - /* lmv structures */ struct lmv_desc { __u32 ld_tgt_count; /* how many MDS's */ @@ -2425,8 +2370,6 @@ static inline __u64 lustre_hash_fnv_1a_64(const void *buf, size_t size) struct lmv_user_md lmv_user_md; }; -void lustre_swab_lmv_mds_md(union lmv_mds_md *lmm); - static inline ssize_t lmv_mds_md_size(int stripe_count, unsigned int lmm_magic) { ssize_t len = -EINVAL; @@ -2530,8 +2473,6 @@ struct lov_desc { #define ld_magic ld_active_tgt_count /* for swabbing from llogs */ -void lustre_swab_lov_desc(struct lov_desc *ld); - /* * LDLM requests: */ @@ -2637,8 +2578,6 @@ struct ldlm_flock_wire { struct ldlm_gl_lquota_desc lquota_desc; }; -void lustre_swab_gl_desc(union ldlm_gl_desc *); - enum ldlm_intent_flags { IT_OPEN = BIT(0), IT_CREAT = BIT(1), @@ -2661,8 +2600,6 @@ struct ldlm_intent { __u64 opc; }; -void lustre_swab_ldlm_intent(struct ldlm_intent *i); - struct ldlm_resource_desc { enum ldlm_type lr_type; __u32 lr_padding; /* also fix lustre_swab_ldlm_resource_desc */ @@ -2686,8 +2623,6 @@ struct ldlm_request { struct lustre_handle lock_handle[LDLM_LOCKREQ_HANDLES]; }; -void lustre_swab_ldlm_request(struct ldlm_request *rq); - /* If LDLM_ENQUEUE, 1 slot is already occupied, 1 is available. * Otherwise, 2 are available. */ @@ -2709,8 +2644,6 @@ struct ldlm_reply { __u64 lock_policy_res2; }; -void lustre_swab_ldlm_reply(struct ldlm_reply *r); - #define ldlm_flags_to_wire(flags) ((__u32)(flags)) #define ldlm_flags_from_wire(flags) ((__u64)(flags)) @@ -2754,8 +2687,6 @@ struct mgs_target_info { char mti_params[MTI_PARAM_MAXLEN]; }; -void lustre_swab_mgs_target_info(struct mgs_target_info *oinfo); - struct mgs_nidtbl_entry { __u64 mne_version; /* table version of this entry */ __u32 mne_instance; /* target instance # */ @@ -2770,8 +2701,6 @@ struct mgs_nidtbl_entry { } u; }; -void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *oinfo); - struct mgs_config_body { char mcb_name[MTI_NAME_MAXLEN]; /* logname */ __u64 mcb_offset; /* next index of config log to request */ @@ -2781,15 +2710,11 @@ struct mgs_config_body { __u32 mcb_units; /* # of units for bulk transfer */ }; -void lustre_swab_mgs_config_body(struct mgs_config_body *body); - struct mgs_config_res { __u64 mcr_offset; /* index of last config log */ __u64 mcr_size; /* size of the log */ }; -void lustre_swab_mgs_config_res(struct mgs_config_res *body); - /* Config marker flags (in config log) */ #define CM_START 0x01 #define CM_END 0x02 @@ -2809,8 +2734,6 @@ struct cfg_marker { char cm_comment[MTI_NAME_MAXLEN]; }; -void lustre_swab_cfg_marker(struct cfg_marker *marker, int swab, int size); - /* * Opcodes for multiple servers. */ @@ -3261,25 +3184,6 @@ struct ll_fiemap_info_key { struct fiemap lfik_fiemap; }; -void lustre_swab_ost_body(struct ost_body *b); -void lustre_swab_ost_last_id(__u64 *id); -void lustre_swab_fiemap(struct fiemap *fiemap); - -void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum); -void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum); -void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod, - int stripe_count); -void lustre_swab_lov_mds_md(struct lov_mds_md *lmm); - -/* llog_swab.c */ -void lustre_swab_llogd_body(struct llogd_body *d); -void lustre_swab_llog_hdr(struct llog_log_hdr *h); -void lustre_swab_llogd_conn_body(struct llogd_conn_body *d); -void lustre_swab_llog_rec(struct llog_rec_hdr *rec); - -struct lustre_cfg; -void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg); - /* Functions for dumping PTLRPC fields */ void dump_rniobuf(struct niobuf_remote *rnb); void dump_ioo(struct obd_ioobj *nb); @@ -3317,8 +3221,6 @@ struct lustre_capa { __u8 lc_hmac[CAPA_HMAC_MAX_LEN]; /** HMAC */ } __packed; -void lustre_swab_lustre_capa(struct lustre_capa *c); - /** lustre_capa::lc_opc */ enum { CAPA_OPC_BODY_WRITE = 1 << 0, /**< write object data */ @@ -3381,8 +3283,6 @@ struct getinfo_fid2path { char gf_path[0]; } __packed; -void lustre_swab_fid2path(struct getinfo_fid2path *gf); - /** path2parent request/reply structures */ struct getparent { struct lu_fid gp_fid; /**< parent FID */ @@ -3409,8 +3309,6 @@ struct layout_intent { __u64 li_end; }; -void lustre_swab_layout_intent(struct layout_intent *li); - /** * On the wire version of hsm_progress structure. * @@ -3429,13 +3327,6 @@ struct hsm_progress_kernel { __u64 hpk_padding2; } __packed; -void lustre_swab_hsm_user_state(struct hsm_user_state *hus); -void lustre_swab_hsm_current_action(struct hsm_current_action *action); -void lustre_swab_hsm_progress_kernel(struct hsm_progress_kernel *hpk); -void lustre_swab_hsm_user_state(struct hsm_user_state *hus); -void lustre_swab_hsm_user_item(struct hsm_user_item *hui); -void lustre_swab_hsm_request(struct hsm_request *hr); - /** layout swap request structure * fid1 and fid2 are in mdt_body */ @@ -3443,8 +3334,6 @@ struct mdc_swap_layouts { __u64 msl_flags; } __packed; -void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl); - struct close_data { struct lustre_handle cd_handle; struct lu_fid cd_fid; @@ -3452,7 +3341,5 @@ struct close_data { __u64 cd_reserved[8]; }; -void lustre_swab_close_data(struct close_data *data); - #endif /** @} lustreidl */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index d964841..3301ad6 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -457,8 +457,6 @@ static inline int lmv_user_md_size(int stripes, int lmm_magic) stripes * sizeof(struct lmv_user_mds_data); } -void lustre_swab_lmv_user_md(struct lmv_user_md *lum); - struct ll_recreate_obj { __u64 lrc_id; __u32 lrc_ost_idx; diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index 89658e0..03a970b 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h @@ -50,6 +50,7 @@ /* Linux specific */ struct key; struct seq_file; +struct lustre_cfg; /* * forward declaration diff --git a/drivers/staging/lustre/lustre/include/lustre_swab.h b/drivers/staging/lustre/lustre/include/lustre_swab.h new file mode 100644 index 0000000..26d01c2 --- /dev/null +++ b/drivers/staging/lustre/lustre/include/lustre_swab.h @@ -0,0 +1,102 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2014, Intel Corporation. + * + * Copyright 2015 Cray Inc, all rights reserved. + * Author: Ben Evans. + * + * We assume all nodes are either little-endian or big-endian, and we + * always send messages in the sender's native format. The receiver + * detects the message format by checking the 'magic' field of the message + * (see lustre_msg_swabbed() below). + * + * Each wire type has corresponding 'lustre_swab_xxxtypexxx()' routines + * are implemented in ptlrpc/lustre_swab.c. These 'swabbers' convert the + * type from "other" endian, in-place in the message buffer. + * + * A swabber takes a single pointer argument. The caller must already have + * verified that the length of the message buffer >= sizeof (type). + * + * For variable length types, a second 'lustre_swab_v_xxxtypexxx()' routine + * may be defined that swabs just the variable part, after the caller has + * verified that the message buffer is large enough. + */ + +#ifndef _LUSTRE_SWAB_H_ +#define _LUSTRE_SWAB_H_ + +#include "lustre/lustre_idl.h" + +void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); +void lustre_swab_connect(struct obd_connect_data *ocd); +void lustre_swab_hsm_user_state(struct hsm_user_state *hus); +void lustre_swab_hsm_state_set(struct hsm_state_set *hss); +void lustre_swab_obd_statfs(struct obd_statfs *os); +void lustre_swab_obd_ioobj(struct obd_ioobj *ioo); +void lustre_swab_niobuf_remote(struct niobuf_remote *nbr); +void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb); +void lustre_swab_ost_lvb(struct ost_lvb *lvb); +void lustre_swab_obd_quotactl(struct obd_quotactl *q); +void lustre_swab_lquota_lvb(struct lquota_lvb *lvb); +void lustre_swab_generic_32s(__u32 *val); +void lustre_swab_mdt_body(struct mdt_body *b); +void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b); +void lustre_swab_mdt_rec_setattr(struct mdt_rec_setattr *sa); +void lustre_swab_mdt_rec_reint(struct mdt_rec_reint *rr); +void lustre_swab_lmv_desc(struct lmv_desc *ld); +void lustre_swab_lmv_mds_md(union lmv_mds_md *lmm); +void lustre_swab_lov_desc(struct lov_desc *ld); +void lustre_swab_gl_desc(union ldlm_gl_desc *desc); +void lustre_swab_ldlm_intent(struct ldlm_intent *i); +void lustre_swab_ldlm_request(struct ldlm_request *rq); +void lustre_swab_ldlm_reply(struct ldlm_reply *r); +void lustre_swab_mgs_target_info(struct mgs_target_info *oinfo); +void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *oinfo); +void lustre_swab_mgs_config_body(struct mgs_config_body *body); +void lustre_swab_mgs_config_res(struct mgs_config_res *body); +void lustre_swab_ost_body(struct ost_body *b); +void lustre_swab_ost_last_id(__u64 *id); +void lustre_swab_fiemap(struct fiemap *fiemap); +void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum); +void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum); +void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod, + int stripe_count); +void lustre_swab_lov_mds_md(struct lov_mds_md *lmm); +void lustre_swab_lustre_capa(struct lustre_capa *c); +void lustre_swab_lustre_capa_key(struct lustre_capa_key *k); +void lustre_swab_fid2path(struct getinfo_fid2path *gf); +void lustre_swab_layout_intent(struct layout_intent *li); +void lustre_swab_hsm_user_state(struct hsm_user_state *hus); +void lustre_swab_hsm_current_action(struct hsm_current_action *action); +void lustre_swab_hsm_progress_kernel(struct hsm_progress_kernel *hpk); +void lustre_swab_hsm_user_state(struct hsm_user_state *hus); +void lustre_swab_hsm_user_item(struct hsm_user_item *hui); +void lustre_swab_hsm_request(struct hsm_request *hr); +void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl); +void lustre_swab_close_data(struct close_data *data); +void lustre_swab_lmv_user_md(struct lmv_user_md *lum); + +#endif diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index d03e6d4..a4a291a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -39,6 +39,7 @@ #include "../../include/linux/libcfs/libcfs.h" #include "../include/lustre_intent.h" +#include "../include/lustre_swab.h" #include "../include/obd_class.h" #include "ldlm_internal.h" diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index ce05493..fc29178 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -51,6 +51,8 @@ #include "../include/lustre_dlm.h" #include "../include/lustre_fid.h" #include "../include/lustre_kernelcomm.h" +#include "../include/lustre_swab.h" + #include "llite_internal.h" /* diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 6c2abb3..6f9b3cb 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -44,6 +44,7 @@ #include #include "../include/lustre/ll_fiemap.h" #include "../include/lustre/lustre_ioctl.h" +#include "../include/lustre_swab.h" #include "../include/cl_object.h" #include "llite_internal.h" diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 5bae584..b236e93 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -48,6 +48,7 @@ #include "../include/lustre_dlm.h" #include "../include/lustre_mds.h" #include "../include/obd_class.h" +#include "../include/lustre_swab.h" #include "../include/lprocfs_status.h" #include "../include/lustre_param.h" #include "../include/cl_object.h" diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 9ba87d2..561b246 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -39,6 +39,7 @@ #define DEBUG_SUBSYSTEM S_LOV #include "../include/lustre_net.h" +#include "../include/lustre_swab.h" #include "../include/obd.h" #include "../include/obd_class.h" #include "../include/obd_support.h" diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 6494c5b..54ebb99 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -38,10 +38,12 @@ #include "../include/obd.h" #include "../include/obd_class.h" #include "../include/lustre_dlm.h" -#include "../include/lustre_fid.h" /* fid_res_name_eq() */ +#include "../include/lustre_fid.h" #include "../include/lustre_mdc.h" #include "../include/lustre_net.h" #include "../include/lustre_req_layout.h" +#include "../include/lustre_swab.h" + #include "mdc_internal.h" struct mdc_getattr_args { diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index f9755dd..087c2cf 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -38,6 +38,7 @@ # include # include +#include "../include/llog_swab.h" #include "../include/lustre_acl.h" #include "../include/lustre/lustre_ioctl.h" #include "../include/obd_class.h" @@ -47,6 +48,7 @@ #include "../include/lustre_param.h" #include "../include/lustre_log.h" #include "../include/lustre_kernelcomm.h" +#include "../include/lustre_swab.h" #include "mdc_internal.h" diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 23600fb..b5370f6 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -43,6 +43,7 @@ #include "../include/lprocfs_status.h" #include "../include/lustre_log.h" #include "../include/lustre_disk.h" +#include "../include/lustre_swab.h" #include "mgc_internal.h" diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index ae63047..073abe3 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -43,6 +43,7 @@ #define DEBUG_SUBSYSTEM S_LOG +#include "../include/llog_swab.h" #include "../include/obd_class.h" #include "../include/lustre_log.h" #include "llog_internal.h" diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index 7869092..723c212 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -38,6 +38,7 @@ #define DEBUG_SUBSYSTEM S_LOG +#include "../include/llog_swab.h" #include "../include/lustre_log.h" static void print_llogd_body(struct llogd_body *d) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 9d5530c..ea68b6d 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -38,6 +38,7 @@ #include "../include/obd_class.h" #include #include "../include/lustre/lustre_ioctl.h" +#include "../include/llog_swab.h" #include "../include/lustre_log.h" #include "../include/lprocfs_status.h" #include "../include/lustre_param.h" diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index 31aa58e..eba7098 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -59,10 +59,12 @@ /* __REQ_LAYOUT_USER__ */ #endif +#include "../include/llog_swab.h" /* struct ptlrpc_request, lustre_msg* */ #include "../include/lustre_req_layout.h" #include "../include/lustre_acl.h" #include "../include/lustre_debug.h" +#include "../include/lustre_swab.h" /* * RQFs (see below) refer to two struct req_msg_field arrays describing the diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 17ec3b6..1178caa 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -42,9 +42,11 @@ #include "../../include/linux/libcfs/libcfs.h" +#include "../include/llog_swab.h" #include "../include/obd_support.h" #include "../include/obd_class.h" #include "../include/lustre_net.h" +#include "../include/lustre_swab.h" #include "../include/obd_cksum.h" #include "../include/lustre/ll_fiemap.h" -- 1.7.1 From jsimmons at infradead.org Fri Dec 2 19:40:50 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 14:40:50 -0500 Subject: [lustre-devel] [PATCH 6/6] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480707650-24089-7-git-send-email-jsimmons@infradead.org> In order for lustre_idl.h to be usable for both user land and kernel space it has to use the proper byteorder functions. Signed-off-by: James Simmons Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245 Reviewed-on: http://review.whamcloud.com/16916 Reviewed-by: Frank Zago Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Reviewed-by: John L. Hammond Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_idl.h | 55 ++++++++++--------- 1 files changed, 29 insertions(+), 26 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index b0fef6d..c207ad6 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -69,6 +69,9 @@ #ifndef _LUSTRE_IDL_H_ #define _LUSTRE_IDL_H_ +#include +#include + #include "../../../include/linux/libcfs/libcfs.h" #include "../../../include/linux/lnet/types.h" @@ -687,30 +690,30 @@ static inline void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen) */ static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src) { - dst->f_seq = cpu_to_le64(fid_seq(src)); - dst->f_oid = cpu_to_le32(fid_oid(src)); - dst->f_ver = cpu_to_le32(fid_ver(src)); + dst->f_seq = __cpu_to_le64(fid_seq(src)); + dst->f_oid = __cpu_to_le32(fid_oid(src)); + dst->f_ver = __cpu_to_le32(fid_ver(src)); } static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src) { - dst->f_seq = le64_to_cpu(fid_seq(src)); - dst->f_oid = le32_to_cpu(fid_oid(src)); - dst->f_ver = le32_to_cpu(fid_ver(src)); + dst->f_seq = __le64_to_cpu(fid_seq(src)); + dst->f_oid = __le32_to_cpu(fid_oid(src)); + dst->f_ver = __le32_to_cpu(fid_ver(src)); } static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src) { - dst->f_seq = cpu_to_be64(fid_seq(src)); - dst->f_oid = cpu_to_be32(fid_oid(src)); - dst->f_ver = cpu_to_be32(fid_ver(src)); + dst->f_seq = __cpu_to_be64(fid_seq(src)); + dst->f_oid = __cpu_to_be32(fid_oid(src)); + dst->f_ver = __cpu_to_be32(fid_ver(src)); } static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src) { - dst->f_seq = be64_to_cpu(fid_seq(src)); - dst->f_oid = be32_to_cpu(fid_oid(src)); - dst->f_ver = be32_to_cpu(fid_ver(src)); + dst->f_seq = __be64_to_cpu(fid_seq(src)); + dst->f_oid = __be32_to_cpu(fid_oid(src)); + dst->f_ver = __be32_to_cpu(fid_ver(src)); } static inline bool fid_is_sane(const struct lu_fid *fid) @@ -747,8 +750,8 @@ static inline void ostid_cpu_to_le(const struct ost_id *src_oi, struct ost_id *dst_oi) { if (fid_seq_is_mdt0(ostid_seq(src_oi))) { - dst_oi->oi.oi_id = cpu_to_le64(src_oi->oi.oi_id); - dst_oi->oi.oi_seq = cpu_to_le64(src_oi->oi.oi_seq); + dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq); } else { fid_cpu_to_le(&dst_oi->oi_fid, &src_oi->oi_fid); } @@ -758,8 +761,8 @@ static inline void ostid_le_to_cpu(const struct ost_id *src_oi, struct ost_id *dst_oi) { if (fid_seq_is_mdt0(ostid_seq(src_oi))) { - dst_oi->oi.oi_id = le64_to_cpu(src_oi->oi.oi_id); - dst_oi->oi.oi_seq = le64_to_cpu(src_oi->oi.oi_seq); + dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq); } else { fid_le_to_cpu(&dst_oi->oi_fid, &src_oi->oi_fid); } @@ -866,7 +869,7 @@ enum lu_dirpage_flags { static inline struct lu_dirent *lu_dirent_start(struct lu_dirpage *dp) { - if (le32_to_cpu(dp->ldp_flags) & LDF_EMPTY) + if (__le32_to_cpu(dp->ldp_flags) & LDF_EMPTY) return NULL; else return dp->ldp_entries; @@ -876,8 +879,8 @@ enum lu_dirpage_flags { { struct lu_dirent *next; - if (le16_to_cpu(ent->lde_reclen) != 0) - next = ((void *)ent) + le16_to_cpu(ent->lde_reclen); + if (__le16_to_cpu(ent->lde_reclen) != 0) + next = ((void *)ent) + __le16_to_cpu(ent->lde_reclen); else next = NULL; @@ -1438,15 +1441,15 @@ static inline __u64 lmm_oi_seq(const struct ost_id *oi) static inline void lmm_oi_le_to_cpu(struct ost_id *dst_oi, const struct ost_id *src_oi) { - dst_oi->oi.oi_id = le64_to_cpu(src_oi->oi.oi_id); - dst_oi->oi.oi_seq = le64_to_cpu(src_oi->oi.oi_seq); + dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq); } static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi, const struct ost_id *src_oi) { - dst_oi->oi.oi_id = cpu_to_le64(src_oi->oi.oi_id); - dst_oi->oi.oi_seq = cpu_to_le64(src_oi->oi.oi_seq); + dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq); } #define MAX_MD_SIZE \ @@ -2378,11 +2381,11 @@ static inline ssize_t lmv_mds_md_size(int stripe_count, unsigned int lmm_magic) static inline int lmv_mds_md_stripe_count_get(const union lmv_mds_md *lmm) { - switch (le32_to_cpu(lmm->lmv_magic)) { + switch (__le32_to_cpu(lmm->lmv_magic)) { case LMV_MAGIC_V1: - return le32_to_cpu(lmm->lmv_md_v1.lmv_stripe_count); + return __le32_to_cpu(lmm->lmv_md_v1.lmv_stripe_count); case LMV_USER_MAGIC: - return le32_to_cpu(lmm->lmv_user_md.lum_stripe_count); + return __le32_to_cpu(lmm->lmv_user_md.lum_stripe_count); default: return -EINVAL; } -- 1.7.1 From jsimmons at infradead.org Fri Dec 2 19:40:48 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 14:40:48 -0500 Subject: [lustre-devel] [PATCH 4/6] staging: lustre: headers: sort headers affected by obdo move In-Reply-To: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480707650-24089-5-git-send-email-jsimmons@infradead.org> From: Ben Evans It was found if you sort the headers alphabetically that it reduced patch conflicts. This patch sorts the headers alphabetically and also place linux header first, then uapi header and finally the lustre kernel headers. Signed-off-by: Ben Evans Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6401 Reviewed-on: http://review.whamcloud.com/16917 Reviewed-on: http://review.whamcloud.com/19266 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/osc_request.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 4d4d3eb..f2365b9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -34,19 +34,20 @@ #include "../../include/linux/libcfs/libcfs.h" -#include "../include/lustre_dlm.h" -#include "../include/lustre_net.h" #include "../include/lustre/lustre_user.h" -#include "../include/obd_cksum.h" +#include "../include/lustre/lustre_ioctl.h" -#include "../include/lustre_ha.h" #include "../include/lprocfs_status.h" -#include "../include/lustre/lustre_ioctl.h" #include "../include/lustre_debug.h" -#include "../include/lustre_param.h" #include "../include/lustre_fid.h" +#include "../include/lustre_ha.h" +#include "../include/lustre_obdo.h" +#include "../include/lustre_param.h" + +#include "../include/obd_cksum.h" #include "../include/obd_class.h" #include "../include/obd.h" + #include "osc_internal.h" #include "osc_cl_internal.h" -- 1.7.1 From jsimmons at infradead.org Fri Dec 2 19:40:47 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 14:40:47 -0500 Subject: [lustre-devel] [PATCH 3/6] staging: lustre: obdclass: Create a header for obdo related functions In-Reply-To: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480707650-24089-4-git-send-email-jsimmons@infradead.org> From: Ben Evans Remove all obdo related functions from lustre_idl.h Create lustre_odbo.h. Include where appropriate. Make the functions lustre_get_wire_obdo and lustre_set_wire_obdo to not be inlined functions. Signed-off-by: Ben Evans Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6401 Reviewed-on: http://review.whamcloud.com/16917 Reviewed-on: http://review.whamcloud.com/19266 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_idl.h | 46 ----------------- .../staging/lustre/lustre/include/lustre_obdo.h | 54 ++++++++++++++++++++ drivers/staging/lustre/lustre/obdclass/obdo.c | 54 ++++++++++++++++++++ drivers/staging/lustre/lustre/osc/osc_io.c | 2 + 4 files changed, 110 insertions(+), 46 deletions(-) create mode 100644 drivers/staging/lustre/lustre/include/lustre_obdo.h diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 6831e4d..52bef77 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -3126,52 +3126,6 @@ struct obdo { #define o_cksum o_nlink #define o_grant_used o_data_version -static inline void lustre_set_wire_obdo(const struct obd_connect_data *ocd, - struct obdo *wobdo, - const struct obdo *lobdo) -{ - *wobdo = *lobdo; - wobdo->o_flags &= ~OBD_FL_LOCAL_MASK; - if (!ocd) - return; - - if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && - fid_seq_is_echo(ostid_seq(&lobdo->o_oi))) { - /* Currently OBD_FL_OSTID will only be used when 2.4 echo - * client communicate with pre-2.4 server - */ - wobdo->o_oi.oi.oi_id = fid_oid(&lobdo->o_oi.oi_fid); - wobdo->o_oi.oi.oi_seq = fid_seq(&lobdo->o_oi.oi_fid); - } -} - -static inline void lustre_get_wire_obdo(const struct obd_connect_data *ocd, - struct obdo *lobdo, - const struct obdo *wobdo) -{ - __u32 local_flags = 0; - - if (lobdo->o_valid & OBD_MD_FLFLAGS) - local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; - - *lobdo = *wobdo; - if (local_flags != 0) { - lobdo->o_valid |= OBD_MD_FLFLAGS; - lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; - lobdo->o_flags |= local_flags; - } - if (!ocd) - return; - - if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && - fid_seq_is_echo(wobdo->o_oi.oi.oi_seq)) { - /* see above */ - lobdo->o_oi.oi_fid.f_seq = wobdo->o_oi.oi.oi_seq; - lobdo->o_oi.oi_fid.f_oid = wobdo->o_oi.oi.oi_id; - lobdo->o_oi.oi_fid.f_ver = 0; - } -} - /* request structure for OST's */ struct ost_body { struct obdo oa; diff --git a/drivers/staging/lustre/lustre/include/lustre_obdo.h b/drivers/staging/lustre/lustre/include/lustre_obdo.h new file mode 100644 index 0000000..1e12f8c --- /dev/null +++ b/drivers/staging/lustre/lustre/include/lustre_obdo.h @@ -0,0 +1,54 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2014, Intel Corporation. + * + * Copyright 2015 Cray Inc, all rights reserved. + * Author: Ben Evans. + * + * Define obdo associated functions + * obdo: OBject Device o... + */ + +#ifndef _LUSTRE_OBDO_H_ +#define _LUSTRE_OBDO_H_ + +#include "lustre/lustre_idl.h" + +/** + * Create an obdo to send over the wire + */ +void lustre_set_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *wobdo, + const struct obdo *lobdo); + +/** + * Create a local obdo from a wire based odbo + */ +void lustre_get_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *lobdo, + const struct obdo *wobdo); + +#endif diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index c52b9e0..b1dfa16 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -40,6 +40,7 @@ #include "../include/obd_class.h" #include "../include/lustre/lustre_idl.h" +#include "../include/lustre_obdo.h" void obdo_set_parent_fid(struct obdo *dst, const struct lu_fid *parent) { @@ -124,3 +125,56 @@ void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj) ioobj->ioo_max_brw = 0; } EXPORT_SYMBOL(obdo_to_ioobj); + +/** + * Create an obdo to send over the wire + */ +void lustre_set_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *wobdo, const struct obdo *lobdo) +{ + *wobdo = *lobdo; + wobdo->o_flags &= ~OBD_FL_LOCAL_MASK; + if (!ocd) + return; + + if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && + fid_seq_is_echo(ostid_seq(&lobdo->o_oi))) { + /* + * Currently OBD_FL_OSTID will only be used when 2.4 echo + * client communicate with pre-2.4 server + */ + wobdo->o_oi.oi.oi_id = fid_oid(&lobdo->o_oi.oi_fid); + wobdo->o_oi.oi.oi_seq = fid_seq(&lobdo->o_oi.oi_fid); + } +} +EXPORT_SYMBOL(lustre_set_wire_obdo); + +/** + * Create a local obdo from a wire based odbo + */ +void lustre_get_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *lobdo, const struct obdo *wobdo) +{ + u32 local_flags = 0; + + if (lobdo->o_valid & OBD_MD_FLFLAGS) + local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; + + *lobdo = *wobdo; + if (local_flags) { + lobdo->o_valid |= OBD_MD_FLFLAGS; + lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; + lobdo->o_flags |= local_flags; + } + if (!ocd) + return; + + if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && + fid_seq_is_echo(wobdo->o_oi.oi.oi_seq)) { + /* see above */ + lobdo->o_oi.oi_fid.f_seq = wobdo->o_oi.oi.oi_seq; + lobdo->o_oi.oi_fid.f_oid = wobdo->o_oi.oi.oi_id; + lobdo->o_oi.oi_fid.f_ver = 0; + } +} +EXPORT_SYMBOL(lustre_get_wire_obdo); diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 97b012d..443a54e 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -37,6 +37,8 @@ #define DEBUG_SUBSYSTEM S_OSC +#include "../include/lustre_obdo.h" + #include "osc_cl_internal.h" /** \addtogroup osc -- 1.7.1 From jsimmons at infradead.org Fri Dec 2 19:40:44 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 14:40:44 -0500 Subject: [lustre-devel] [PATCH 0/6] Fix ups to make lustre_idl.h a proper UAPI header Message-ID: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> The header lustre_idl.h is a UAPI header which contains extras that don't belong. This patch set moves a bunch of very kernel specific material out of the header. Lastly proper byteorder functions are used so this file can build in user space as well. Ben Evans (5): staging: lustre: headers: move swab functions to new header files staging: lustre: headers: sort headers affected by swab move staging: lustre: obdclass: Create a header for obdo related functions staging: lustre: headers: sort headers affected by obdo move staging: lustre: headers: Move functions out of lustre_idl.h James Simmons (1): staging: lustre: headers: use proper byteorder functions in lustre_idl.h drivers/staging/lustre/lustre/include/llog_swab.h | 65 +++++ .../staging/lustre/lustre/include/lprocfs_status.h | 2 + .../lustre/lustre/include/lustre/lustre_idl.h | 289 ++------------------ .../lustre/lustre/include/lustre/lustre_user.h | 2 - drivers/staging/lustre/lustre/include/lustre_dlm.h | 13 + .../staging/lustre/lustre/include/lustre_obdo.h | 54 ++++ drivers/staging/lustre/lustre/include/lustre_sec.h | 1 + .../staging/lustre/lustre/include/lustre_swab.h | 108 ++++++++ drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 6 + drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 27 ++ drivers/staging/lustre/lustre/llite/dir.c | 2 + drivers/staging/lustre/lustre/llite/file.c | 1 + drivers/staging/lustre/lustre/lov/lov_obd.c | 18 +- drivers/staging/lustre/lustre/lov/lov_pack.c | 7 +- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 6 + drivers/staging/lustre/lustre/mdc/mdc_locks.c | 4 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 13 +- drivers/staging/lustre/lustre/mgc/mgc_request.c | 8 +- drivers/staging/lustre/lustre/obdclass/llog.c | 3 +- drivers/staging/lustre/lustre/obdclass/llog_swab.c | 1 + .../staging/lustre/lustre/obdclass/obd_config.c | 7 +- drivers/staging/lustre/lustre/obdclass/obdo.c | 54 ++++ drivers/staging/lustre/lustre/osc/osc_io.c | 2 + drivers/staging/lustre/lustre/osc/osc_request.c | 13 +- drivers/staging/lustre/lustre/ptlrpc/layout.c | 12 +- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 9 +- 27 files changed, 430 insertions(+), 298 deletions(-) create mode 100644 drivers/staging/lustre/lustre/include/llog_swab.h create mode 100644 drivers/staging/lustre/lustre/include/lustre_obdo.h create mode 100644 drivers/staging/lustre/lustre/include/lustre_swab.h From andreas.dilger at intel.com Fri Dec 2 21:53:08 2016 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Fri, 2 Dec 2016 21:53:08 +0000 Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging Message-ID: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> Al, Greg recently raised the issue of what still needs to be done to move the Lustre code out of staging/ and into the fs/ tree. James has been doing a great job of cleaning up various checkpatch issues and keeping the code updated with the latest fixes, but we were wondering what you were aware of that needed to be cleaned up in Lustre? Cheers, Andreas From jsimmons at infradead.org Sat Dec 3 00:53:07 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:07 -0500 Subject: [lustre-devel] [PATCH 00/22] Next batch of missing work for upstream client Message-ID: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Batch of various fixes and clean ups missing in the upstream client. Only one smaller batch of patches left to sync lustre 2.8.0 version. These patches are independent of each other so they can be landed in any order. Alex Zhuravlev (1): staging: lustre: obdclass: lu_site_purge() to handle purge-all Alexander Boyko (1): staging: lustre: obd: add callback for llog_cat_process_or_fork Alexander Zarochentsev (1): staging: lustre: libcfs: remove lnet upcall code Ashish Purkar (1): staging: lustre: osc: fix debug log message formatting Bobi Jam (1): staging: lustre: clio: remove mtime check in vvp_io_fault_start() Fan Yong (1): staging: lustre: statahead: set sai_index_wait with lli_sa_lock held Jinshan Xiong (5): staging: lustre: llite: clear LLIF_DATA_MODIFIED in atomic staging: lustre: osc: handle osc eviction correctly staging: lustre: clio: revise read ahead algorithm staging: lustre: rpc: increase bulk size staging: lustre: osc: set lock data for readahead lock Li Dongyang (2): staging: lustre: obdclass: limit lu_site hash table size on clients staging: lustre: mdt: fail FMODE_WRITE open if the client is read only Mikhal Pershin (1): staging: lustre: import: don't reconnect during connect interpret Parinay Kondekar (1): staging: lustre: llite: ll_dir_ioctl cleanup of redundant comparisons Wally Wang (1): staging: lustre: llite: Add client mount opt to ignore suppress_pings Yang Sheng (3): staging: lustre: libcfs: report hnode value for cfs_hash_putref staging: lustre: llite: Invoke file_update_time in page_mkwrite staging: lustre: remove set but unused variables wang di (3): staging: lustre: mdt: race between open and migrate staging: lustre: lmv: remove nlink check in lmv_revalidate_slaves staging: lustre: llog: reset llog bitmap .../staging/lustre/include/linux/libcfs/libcfs.h | 1 - .../lustre/include/linux/libcfs/libcfs_private.h | 2 - drivers/staging/lustre/lnet/libcfs/hash.c | 2 +- .../staging/lustre/lnet/libcfs/linux/linux-debug.c | 54 -------- drivers/staging/lustre/lnet/libcfs/module.c | 8 - drivers/staging/lustre/lnet/lnet/nidstrings.c | 2 - .../lustre/lustre/include/lustre/lustre_idl.h | 6 +- .../staging/lustre/lustre/include/lustre_import.h | 4 +- drivers/staging/lustre/lustre/include/lustre_net.h | 8 +- .../lustre/lustre/include/lustre_req_layout.h | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 3 +- drivers/staging/lustre/lustre/llite/dir.c | 5 +- drivers/staging/lustre/lustre/llite/file.c | 137 +++++++++++++------- .../staging/lustre/lustre/llite/llite_internal.h | 22 ++-- drivers/staging/lustre/lustre/llite/llite_lib.c | 34 +++--- drivers/staging/lustre/lustre/llite/llite_mmap.c | 8 +- drivers/staging/lustre/lustre/llite/namei.c | 4 + drivers/staging/lustre/lustre/llite/rw.c | 71 ++++++----- drivers/staging/lustre/lustre/llite/statahead.c | 18 ++- drivers/staging/lustre/lustre/llite/vvp_io.c | 16 +-- drivers/staging/lustre/lustre/llite/xattr_cache.c | 7 +- drivers/staging/lustre/lustre/lmv/lmv_intent.c | 16 +-- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 59 +++++---- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 20 +++- drivers/staging/lustre/lustre/obdclass/llog.c | 7 + drivers/staging/lustre/lustre/obdclass/llog_cat.c | 16 +-- drivers/staging/lustre/lustre/obdclass/lu_object.c | 9 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 25 ++-- .../staging/lustre/lustre/osc/osc_cl_internal.h | 11 +- drivers/staging/lustre/lustre/osc/osc_internal.h | 2 + drivers/staging/lustre/lustre/osc/osc_io.c | 61 +++++++-- drivers/staging/lustre/lustre/osc/osc_lock.c | 7 +- drivers/staging/lustre/lustre/osc/osc_object.c | 19 +++ drivers/staging/lustre/lustre/osc/osc_page.c | 2 +- drivers/staging/lustre/lustre/osc/osc_request.c | 94 +++++++------- drivers/staging/lustre/lustre/ptlrpc/import.c | 16 ++- drivers/staging/lustre/lustre/ptlrpc/layout.c | 18 +++ drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 2 + 38 files changed, 452 insertions(+), 345 deletions(-) From jsimmons at infradead.org Sat Dec 3 00:53:12 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:12 -0500 Subject: [lustre-devel] [PATCH 05/22] staging: lustre: lmv: remove nlink check in lmv_revalidate_slaves In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-6-git-send-email-jsimmons@infradead.org> From: wang di Remove nlink < 2 check in lmv_revalidate_slaves, because after nlink reaches to LDISKFS_LINK_MAX (65000), the inode nlink will be set to 1. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6984 Reviewed-on: http://review.whamcloud.com/16490 Reviewed-by: James Simmons Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lmv/lmv_intent.c | 16 +--------------- 1 files changed, 1 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index b1071cf..aa42066 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -220,21 +220,7 @@ int lmv_revalidate_slaves(struct obd_export *exp, /* refresh slave from server */ body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - LASSERT(body); - - if (unlikely(body->mbo_nlink < 2)) { - /* - * If this is bad stripe, most likely due - * to the race between close(unlink) and - * getattr, let's return -EONENT, so llite - * will revalidate the dentry see - * ll_inode_revalidate_fini() - */ - CDEBUG(D_INODE, "%s: nlink %d < 2 corrupt stripe %d "DFID":" DFID"\n", - obd->obd_name, body->mbo_nlink, i, - PFID(&lsm->lsm_md_oinfo[i].lmo_fid), - PFID(&lsm->lsm_md_oinfo[0].lmo_fid)); - + if (!body) { if (it.it_lock_mode && lockh) { ldlm_lock_decref(lockh, it.it_lock_mode); it.it_lock_mode = 0; -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:08 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:08 -0500 Subject: [lustre-devel] [PATCH 01/22] staging: lustre: llite: clear LLIF_DATA_MODIFIED in atomic In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-2-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong This flag should be cleared atomically after the op_data flag MDS_DATA_MODIFIED is packed. Otherwise, if there exists an operation to dirty the file again, the state may be missed on the MDT. Stop using spin lock lli_lock to protect operations of changing file flags; using bit operations instead. Signed-off-by: Jinshan Xiong Signed-off-by: James Simmons Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6377 Reviewed-on: http://review.whamcloud.com/14100 Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/file.c | 61 +++++++------------ .../staging/lustre/lustre/llite/llite_internal.h | 12 ++-- drivers/staging/lustre/lustre/llite/llite_lib.c | 18 +------ drivers/staging/lustre/lustre/llite/llite_mmap.c | 7 +-- drivers/staging/lustre/lustre/llite/vvp_io.c | 10 +-- drivers/staging/lustre/lustre/llite/xattr_cache.c | 7 +- 6 files changed, 38 insertions(+), 77 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 6c2abb3..ea21e19 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -75,45 +75,39 @@ static void ll_file_data_put(struct ll_file_data *fd) kmem_cache_free(ll_file_data_slab, fd); } -void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, - struct lustre_handle *fh) +/** + * Packs all the attributes into @op_data for the CLOSE rpc. + */ +static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data, + struct obd_client_handle *och) { - op_data->op_fid1 = ll_i2info(inode)->lli_fid; + struct ll_inode_info *lli = ll_i2info(inode); + + ll_prep_md_op_data(op_data, inode, NULL, NULL, + 0, 0, LUSTRE_OPC_ANY, NULL); + op_data->op_attr.ia_mode = inode->i_mode; op_data->op_attr.ia_atime = inode->i_atime; op_data->op_attr.ia_mtime = inode->i_mtime; op_data->op_attr.ia_ctime = inode->i_ctime; op_data->op_attr.ia_size = i_size_read(inode); + op_data->op_attr.ia_valid |= ATTR_MODE | ATTR_ATIME | ATTR_ATIME_SET | + ATTR_MTIME | ATTR_MTIME_SET | + ATTR_CTIME | ATTR_CTIME_SET; op_data->op_attr_blocks = inode->i_blocks; op_data->op_attr_flags = ll_inode_to_ext_flags(inode->i_flags); - if (fh) - op_data->op_handle = *fh; + op_data->op_handle = och->och_fh; - if (ll_i2info(inode)->lli_flags & LLIF_DATA_MODIFIED) + /* + * For HSM: if inode data has been modified, pack it so that + * MDT can set data dirty flag in the archive. + */ + if (och->och_flags & FMODE_WRITE && + test_and_clear_bit(LLIF_DATA_MODIFIED, &lli->lli_flags)) op_data->op_bias |= MDS_DATA_MODIFIED; } /** - * Packs all the attributes into @op_data for the CLOSE rpc. - */ -static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data, - struct obd_client_handle *och) -{ - op_data->op_attr.ia_valid = ATTR_MODE | ATTR_ATIME | ATTR_ATIME_SET | - ATTR_MTIME | ATTR_MTIME_SET | - ATTR_CTIME | ATTR_CTIME_SET; - - if (!(och->och_flags & FMODE_WRITE)) - goto out; - - op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS; -out: - ll_pack_inode2opdata(inode, op_data, &och->och_fh); - ll_prep_md_op_data(op_data, inode, NULL, NULL, - 0, 0, LUSTRE_OPC_ANY, NULL); -} - -/** * Perform a close, possibly with a bias. * The meaning of "data" depends on the value of "bias". * @@ -181,17 +175,6 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, PFID(ll_inode2fid(inode)), rc); } - /* DATA_MODIFIED flag was successfully sent on close, cancel data - * modification flag. - */ - if (rc == 0 && (op_data->op_bias & MDS_DATA_MODIFIED)) { - struct ll_inode_info *lli = ll_i2info(inode); - - spin_lock(&lli->lli_lock); - lli->lli_flags &= ~LLIF_DATA_MODIFIED; - spin_unlock(&lli->lli_lock); - } - if (op_data->op_bias & (MDS_HSM_RELEASE | MDS_CLOSE_LAYOUT_SWAP) && !rc) { struct mdt_body *body; @@ -2888,6 +2871,8 @@ static int ll_inode_revalidate(struct dentry *dentry, __u64 ibits) LTIME_S(inode->i_mtime) = ll_i2info(inode)->lli_mtime; LTIME_S(inode->i_ctime) = ll_i2info(inode)->lli_ctime; } else { + struct ll_inode_info *lli = ll_i2info(inode); + /* In case of restore, the MDT has the right size and has * already send it back without granting the layout lock, * inode is up-to-date so glimpse is useless. @@ -2895,7 +2880,7 @@ static int ll_inode_revalidate(struct dentry *dentry, __u64 ibits) * restore the MDT holds the layout lock so the glimpse will * block up to the end of restore (getattr will block) */ - if (!(ll_i2info(inode)->lli_flags & LLIF_FILE_RESTORING)) + if (!test_bit(LLIF_FILE_RESTORING, &lli->lli_flags)) rc = ll_glimpse_size(inode); } return rc; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 50bb328..ac4ce05 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -97,20 +97,20 @@ struct ll_grouplock { unsigned long lg_gid; }; -enum lli_flags { +enum ll_file_flags { /* File data is modified. */ - LLIF_DATA_MODIFIED = BIT(0), + LLIF_DATA_MODIFIED = 0, /* File is being restored */ - LLIF_FILE_RESTORING = BIT(1), + LLIF_FILE_RESTORING = 1, /* Xattr cache is attached to the file */ - LLIF_XATTR_CACHE = BIT(2), + LLIF_XATTR_CACHE = 2, }; struct ll_inode_info { __u32 lli_inode_magic; - __u32 lli_flags; spinlock_t lli_lock; + unsigned long lli_flags; struct posix_acl *lli_posix_acl; /* identifying fields for both metadata and data stacks. */ @@ -740,8 +740,6 @@ enum ldlm_mode ll_take_md_lock(struct inode *inode, __u64 bits, int ll_file_release(struct inode *inode, struct file *file); int ll_release_openhandle(struct inode *, struct lookup_intent *); int ll_md_real_close(struct inode *inode, fmode_t fmode); -void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, - struct lustre_handle *fh); int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat); struct posix_acl *ll_get_acl(struct inode *inode, int type); int ll_migrate(struct inode *parent, struct file *file, int mdtidx, diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index dcd9240..2a51efa 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1532,9 +1532,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) * modified, flag it. */ attr->ia_valid |= MDS_OPEN_OWNEROVERRIDE; - spin_lock(&lli->lli_lock); - lli->lli_flags |= LLIF_DATA_MODIFIED; - spin_unlock(&lli->lli_lock); op_data->op_bias |= MDS_DATA_MODIFIED; } } @@ -1545,13 +1542,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) if (rc) goto out; - /* RPC to MDT is sent, cancel data modification flag */ - if (op_data->op_bias & MDS_DATA_MODIFIED) { - spin_lock(&lli->lli_lock); - lli->lli_flags &= ~LLIF_DATA_MODIFIED; - spin_unlock(&lli->lli_lock); - } - if (!S_ISREG(inode->i_mode) || file_is_released) { rc = 0; goto out; @@ -1822,7 +1812,7 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md) if (body->mbo_valid & OBD_MD_TSTATE) { if (body->mbo_t_state & MS_RESTORE) - lli->lli_flags |= LLIF_FILE_RESTORING; + set_bit(LLIF_FILE_RESTORING, &lli->lli_flags); } return 0; @@ -2331,8 +2321,6 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid()); op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid()); op_data->op_cap = cfs_curproc_cap_pack(); - op_data->op_bias = 0; - op_data->op_cli_flags = 0; if ((opc == LUSTRE_OPC_CREATE) && name && filename_is_volatile(name, namelen, &op_data->op_mds)) op_data->op_bias |= MDS_CREATE_VOLATILE; @@ -2340,10 +2328,6 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, op_data->op_mds = 0; op_data->op_data = data; - /* When called by ll_setattr_raw, file is i1. */ - if (ll_i2info(i1)->lli_flags & LLIF_DATA_MODIFIED) - op_data->op_bias |= MDS_DATA_MODIFIED; - return op_data; } diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index b56203b..f50b6c1 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -215,11 +215,8 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, result = -EAGAIN; } - if (result == 0) { - spin_lock(&lli->lli_lock); - lli->lli_flags |= LLIF_DATA_MODIFIED; - spin_unlock(&lli->lli_lock); - } + if (!result) + set_bit(LLIF_DATA_MODIFIED, &lli->lli_flags); } out_io: diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 2bf3e47..114906d 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -329,8 +329,8 @@ static void vvp_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) vio->vui_layout_gen, gen); /* today successful restore is the only possible case */ /* restore was done, clear restoring state */ - ll_i2info(vvp_object_inode(obj))->lli_flags &= - ~LLIF_FILE_RESTORING; + clear_bit(LLIF_FILE_RESTORING, + &ll_i2info(inode)->lli_flags); } } } @@ -982,11 +982,7 @@ static int vvp_io_write_start(const struct lu_env *env, } } if (result > 0) { - struct ll_inode_info *lli = ll_i2info(inode); - - spin_lock(&lli->lli_lock); - lli->lli_flags |= LLIF_DATA_MODIFIED; - spin_unlock(&lli->lli_lock); + set_bit(LLIF_DATA_MODIFIED, &(ll_i2info(inode))->lli_flags); if (result < cnt) io->ci_continue = 0; diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index 47c1d11..198b051 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -60,7 +60,7 @@ void ll_xattr_fini(void) static void ll_xattr_cache_init(struct ll_inode_info *lli) { INIT_LIST_HEAD(&lli->lli_xattrs); - lli->lli_flags |= LLIF_XATTR_CACHE; + set_bit(LLIF_XATTR_CACHE, &lli->lli_flags); } /** @@ -216,7 +216,7 @@ static int ll_xattr_cache_list(struct list_head *cache, */ static int ll_xattr_cache_valid(struct ll_inode_info *lli) { - return !!(lli->lli_flags & LLIF_XATTR_CACHE); + return test_bit(LLIF_XATTR_CACHE, &lli->lli_flags); } /** @@ -233,7 +233,8 @@ static int ll_xattr_cache_destroy_locked(struct ll_inode_info *lli) while (ll_xattr_cache_del(&lli->lli_xattrs, NULL) == 0) ; /* empty loop */ - lli->lli_flags &= ~LLIF_XATTR_CACHE; + + clear_bit(LLIF_XATTR_CACHE, &lli->lli_flags); return 0; } -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:18 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:18 -0500 Subject: [lustre-devel] [PATCH 11/22] staging: lustre: mdt: fail FMODE_WRITE open if the client is read only In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-12-git-send-email-jsimmons@infradead.org> From: Li Dongyang O_WRONLY/O_RDWR open on a file will get EROFS on a read only client, but the rpc gets sent to the mdt anyway. mdt will increase the mot_write_count of the mdt object, blocking subsequent FMODE_EXEC open to the same file. This patch makes sure we fail the FMODE_WRITE open with EROFS on the client straight away without sending the rpc to mdt. Signed-off-by: Li Dongyang Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7727 Reviewed-on: http://review.whamcloud.com/18242 Reviewed-by: Ian Costello Reviewed-by: Nathaniel Clark Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/namei.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index b07079c..9426759 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -572,6 +572,10 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, } } + if (it->it_op & IT_OPEN && it->it_flags & FMODE_WRITE && + dentry->d_sb->s_flags & MS_RDONLY) + return ERR_PTR(-EROFS); + if (it->it_op & IT_CREAT) opc = LUSTRE_OPC_CREATE; else -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:19 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:19 -0500 Subject: [lustre-devel] [PATCH 12/22] staging: lustre: libcfs: report hnode value for cfs_hash_putref In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-13-git-send-email-jsimmons@infradead.org> From: Yang Sheng Add more debugging info. Signed-off-by: Yang Sheng Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7084 Reviewed-on: http://review.whamcloud.com/17673 Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lnet/libcfs/hash.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c b/drivers/staging/lustre/lnet/libcfs/hash.c index b90dfb9..c93c59d 100644 --- a/drivers/staging/lustre/lnet/libcfs/hash.c +++ b/drivers/staging/lustre/lnet/libcfs/hash.c @@ -1215,7 +1215,7 @@ void cfs_hash_putref(struct cfs_hash *hs) struct cfs_hash_bd bds[2]; int bits = 0; - LASSERT(hlist_unhashed(hnode)); + LASSERTF(hlist_unhashed(hnode), "hnode = %p\n", hnode); cfs_hash_lock(hs, 0); cfs_hash_dual_bd_get_and_lock(hs, key, bds, 1); -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:17 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:17 -0500 Subject: [lustre-devel] [PATCH 10/22] staging: lustre: obdclass: limit lu_site hash table size on clients In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-11-git-send-email-jsimmons@infradead.org> From: Li Dongyang Allocating a big hash table using the current formula does not really work for clients. We will create new hash table for each mount on a single client which is a lot of memory more than expected. This patch limits the hash table up to 8M for clients, which has 524288 entries. Signed-off-by: Li Dongyang Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7689 Reviewed-on: http://review.whamcloud.com/18048 Reviewed-by: Fan Yong Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/lu_object.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index a02aaa3..80e0984 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -68,6 +68,7 @@ enum { #define LU_SITE_BITS_MIN 12 #define LU_SITE_BITS_MAX 24 +#define LU_SITE_BITS_MAX_CL 19 /** * total 256 buckets, we don't want too many buckets because: * - consume too much memory @@ -878,6 +879,9 @@ static unsigned long lu_htable_order(struct lu_device *top) unsigned long cache_size; unsigned long bits; + if (!strcmp(top->ld_type->ldt_name, LUSTRE_VVP_NAME)) + bits_max = LU_SITE_BITS_MAX_CL; + /* * Calculate hash table size, assuming that we want reasonable * performance when 20% of total memory is occupied by cache of -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:23 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:23 -0500 Subject: [lustre-devel] [PATCH 16/22] staging: lustre: llite: Invoke file_update_time in page_mkwrite In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-17-git-send-email-jsimmons@infradead.org> From: Yang Sheng Only update file times if page_mkwrite is not set. So we need call file_update_time by ourselves. Signed-off-by: Yang Sheng Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1118 Reviewed-on: http://review.whamcloud.com/18683 Reviewed-by: Andreas Dilger Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_mmap.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index f50b6c1..ee01f20 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -369,6 +369,7 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) bool retry; int result; + file_update_time(vma->vm_file); do { retry = false; result = ll_page_mkwrite0(vma, vmf->page, &retry); -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:16 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:16 -0500 Subject: [lustre-devel] [PATCH 09/22] staging: lustre: llite: Add client mount opt to ignore suppress_pings In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-10-git-send-email-jsimmons@infradead.org> From: Wally Wang When Lustre servers enable 'suppress_pings', all clients will stop pinging. However, some clients may not have external mechanism to notify Lustre servers for node death and therefore need to preserve the Lustre ping. This patch provides a mount option 'always_ping' so that the client will not stop pinging even if the server has enabled 'suppress_pings'. Signed-off-by: Wally Wang Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6391 Reviewed-on: http://review.whamcloud.com/14127 Reviewed-by: Li Wei Reviewed-by: Chris Horn Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/llite/llite_internal.h | 3 +++ drivers/staging/lustre/lustre/llite/llite_lib.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index e37ba1f..2f46d47 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -391,6 +391,8 @@ enum stats_track_type { #define LL_SBI_USER_FID2PATH 0x40000 /* allow fid2path by unprivileged users */ #define LL_SBI_XATTR_CACHE 0x80000 /* support for xattr cache */ #define LL_SBI_NOROOTSQUASH 0x100000 /* do not apply root squash */ +#define LL_SBI_ALWAYS_PING 0x200000 /* always ping even if server + * suppress_pings */ #define LL_SBI_FLAGS { \ "nolck", \ @@ -414,6 +416,7 @@ enum stats_track_type { "user_fid2path",\ "xattr_cache", \ "norootsquash", \ + "always_ping", \ } /* diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 2a51efa..25f5aed 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -224,6 +224,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, /* real client */ data->ocd_connect_flags |= OBD_CONNECT_REAL; + /* always ping even if server suppress_pings */ + if (sbi->ll_flags & LL_SBI_ALWAYS_PING) + data->ocd_connect_flags &= ~OBD_CONNECT_PINGLESS; + data->ocd_brw_size = MD_MAX_BRW_SIZE; err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, @@ -373,6 +377,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE; + /* always ping even if server suppress_pings */ + if (sbi->ll_flags & LL_SBI_ALWAYS_PING) + data->ocd_connect_flags &= ~OBD_CONNECT_PINGLESS; + CDEBUG(D_RPCTRACE, "ocd_connect_flags: %#llx ocd_version: %d ocd_grant: %d\n", data->ocd_connect_flags, data->ocd_version, data->ocd_grant); @@ -788,6 +796,11 @@ static int ll_options(char *options, int *flags) *flags &= ~tmp; goto next; } + tmp = ll_set_opt("always_ping", s1, LL_SBI_ALWAYS_PING); + if (tmp) { + *flags |= tmp; + goto next; + } LCONSOLE_ERROR_MSG(0x152, "Unknown option '%s', won't mount.\n", s1); return -EINVAL; @@ -2361,6 +2374,9 @@ int ll_show_options(struct seq_file *seq, struct dentry *dentry) if (sbi->ll_flags & LL_SBI_USER_FID2PATH) seq_puts(seq, ",user_fid2path"); + if (sbi->ll_flags & LL_SBI_ALWAYS_PING) + seq_puts(seq, ",always_ping"); + return 0; } -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:24 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:24 -0500 Subject: [lustre-devel] [PATCH 17/22] staging: lustre: clio: remove mtime check in vvp_io_fault_start() In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-18-git-send-email-jsimmons@infradead.org> From: Bobi Jam In fault IO initialization, inode's mtime is saved, and after getting locks, when the IO is about to start, vvp_io_fault_start() checks the mtime's intactness. It's a false alarm, since the timestamp from MDS could be stale, we maintain mtime mainly on OST objects, and if the check in vvp_io_fault_start() happens before mtime on OST objects are merged, it will get wrong timestamp from the inode, even the timestamp it fetched in vvp_io_fault_init() could be wrong in the first place. This patch remove the mtime check in vvp_io_fault_start(). Signed-off-by: Bobi Jam Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7198 Reviewed-on: http://review.whamcloud.com/19162 Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/vvp_io.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 114906d..0b6d388 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -1064,12 +1064,6 @@ static int vvp_io_fault_start(const struct lu_env *env, loff_t size; pgoff_t last_index; - if (fio->ft_executable && - inode->i_mtime.tv_sec != vio->u.fault.ft_mtime) - CWARN("binary "DFID - " changed while waiting for the page fault lock\n", - PFID(lu_object_fid(&obj->co_lu))); - down_read(&lli->lli_trunc_sem); /* offset of the last byte on the page */ -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:27 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:27 -0500 Subject: [lustre-devel] [PATCH 20/22] staging: lustre: osc: set lock data for readahead lock In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-21-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong If osc_io_readahead() finds a lock that belongs to the previous instance of osc_object, the lock data pointer will be null. It has to instantiate with new instance otherwise those pages won't be destroyed at lock cancel, and then finally hit the assertion in osc_req_attr_set(). This patch revised dlmlock_at_pgoff() to call osc_match_base() to find caching locks for readahead. And new osc_object will be set to the lock if it doesn't have one yet. Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8005 Reviewed-on: http://review.whamcloud.com/19453 Reviewed-by: Bobi Jam Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/osc_io.c | 1 + drivers/staging/lustre/lustre/osc/osc_lock.c | 7 +-- drivers/staging/lustre/lustre/osc/osc_request.c | 49 ++++++---------------- 3 files changed, 18 insertions(+), 39 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 369761f..d96f4f2 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -88,6 +88,7 @@ static int osc_io_read_ahead(const struct lu_env *env, dlmlock = osc_dlmlock_at_pgoff(env, osc, start, 0); if (dlmlock) { + LASSERT(dlmlock->l_ast_data == osc); if (dlmlock->l_req_mode != LCK_PR) { struct lustre_handle lockh; diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 130460d..001fe75 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -1205,10 +1205,9 @@ struct ldlm_lock *osc_dlmlock_at_pgoff(const struct lu_env *env, * with a uniq gid and it conflicts with all other lock modes too */ again: - mode = ldlm_lock_match(osc_export(obj)->exp_obd->obd_namespace, - flags, resname, LDLM_EXTENT, policy, - LCK_PR | LCK_PW | LCK_GROUP, &lockh, - dap_flags & OSC_DAP_FL_CANCELING); + mode = osc_match_base(osc_export(obj), resname, LDLM_EXTENT, policy, + LCK_PR | LCK_PW | LCK_GROUP, &flags, obj, &lockh, + dap_flags & OSC_DAP_FL_CANCELING); if (mode != 0) { lock = ldlm_handle2lock(&lockh); /* RACE: the lock is cancelled so let's try again */ diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index bc698d3..0977127 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -1813,16 +1813,11 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, return rc; } -static int osc_set_lock_data_with_check(struct ldlm_lock *lock, - struct ldlm_enqueue_info *einfo) +static int osc_set_lock_data(struct ldlm_lock *lock, void *data) { - void *data = einfo->ei_cbdata; int set = 0; - LASSERT(lock->l_blocking_ast == einfo->ei_cb_bl); - LASSERT(lock->l_resource->lr_type == einfo->ei_type); - LASSERT(lock->l_completion_ast == einfo->ei_cb_cp); - LASSERT(lock->l_glimpse_ast == einfo->ei_cb_gl); + LASSERT(lock); lock_res_and_lock(lock); @@ -1836,21 +1831,6 @@ static int osc_set_lock_data_with_check(struct ldlm_lock *lock, return set; } -static int osc_set_data_with_check(struct lustre_handle *lockh, - struct ldlm_enqueue_info *einfo) -{ - struct ldlm_lock *lock = ldlm_handle2lock(lockh); - int set = 0; - - if (lock) { - set = osc_set_lock_data_with_check(lock, einfo); - LDLM_LOCK_PUT(lock); - } else - CERROR("lockh %p, data %p - client evicted?\n", - lockh, einfo->ei_cbdata); - return set; -} - static int osc_enqueue_fini(struct ptlrpc_request *req, osc_enqueue_upcall_f upcall, void *cookie, struct lustre_handle *lockh, enum ldlm_mode mode, @@ -2016,7 +1996,7 @@ 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)) { + } else if (osc_set_lock_data(matched, einfo->ei_cbdata)) { *flags |= LDLM_FL_LVB_READY; /* We already have a lock, and it's referenced. */ (*upcall)(cookie, &lockh, ELDLM_LOCK_MATCHED); @@ -2128,19 +2108,18 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, rc |= LCK_PW; rc = ldlm_lock_match(obd->obd_namespace, lflags, res_id, type, policy, rc, lockh, unref); - if (rc) { - if (data) { - if (!osc_set_data_with_check(lockh, data)) { - if (!(lflags & LDLM_FL_TEST_LOCK)) - ldlm_lock_decref(lockh, rc); - return 0; - } - } - if (!(lflags & LDLM_FL_TEST_LOCK) && mode != rc) { - ldlm_lock_addref(lockh, LCK_PR); - ldlm_lock_decref(lockh, LCK_PW); - } + if (!rc || lflags & LDLM_FL_TEST_LOCK) return rc; + + if (data) { + struct ldlm_lock *lock = ldlm_handle2lock(lockh); + + LASSERT(lock); + if (!osc_set_lock_data(lock, data)) { + ldlm_lock_decref(lockh, rc); + rc = 0; + } + LDLM_LOCK_PUT(lock); } return rc; } -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:15 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:15 -0500 Subject: [lustre-devel] [PATCH 08/22] staging: lustre: clio: revise read ahead algorithm In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-9-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong ras_window_len should only be updated in ras_update() by read pattern and it can't be adjusted in ll_readahead() at all; ras_consecutive_pages is used to detect read pattern from mmap. It will be used to increase read ahead window length gradually. Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5505 Reviewed-on: http://review.whamcloud.com/11528 Reviewed-by: John L. Hammond Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/llite/llite_internal.h | 5 +- drivers/staging/lustre/lustre/llite/rw.c | 71 +++++++++++--------- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index ae0bb09..e37ba1f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -1005,8 +1005,11 @@ int ll_xattr_list(struct inode *inode, const char *name, int type, */ int cl_sb_init(struct super_block *sb); int cl_sb_fini(struct super_block *sb); -void ll_io_init(struct cl_io *io, const struct file *file, int write); +enum ras_update_flags { + LL_RAS_HIT = 0x1, + LL_RAS_MMAP = 0x2 +}; void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len); void ll_ra_stats_inc(struct inode *inode, enum ra_stat which); diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index e34017d..e2d5e75 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -457,30 +457,25 @@ static int ll_readahead(const struct lu_env *env, struct cl_io *io, spin_lock(&ras->ras_lock); - /* Enlarge the RA window to encompass the full read */ - if (vio->vui_ra_valid && - ras->ras_window_start + ras->ras_window_len < - vio->vui_ra_start + vio->vui_ra_count) { - ras->ras_window_len = vio->vui_ra_start + vio->vui_ra_count - - ras->ras_window_start; - } + /** + * Note: other thread might rollback the ras_next_readahead, + * if it can not get the full size of prepared pages, see the + * end of this function. For stride read ahead, it needs to + * make sure the offset is no less than ras_stride_offset, + * so that stride read ahead can work correctly. + */ + if (stride_io_mode(ras)) + start = max(ras->ras_next_readahead, ras->ras_stride_offset); + else + start = ras->ras_next_readahead; - /* Reserve a part of the read-ahead window that we'll be issuing */ - if (ras->ras_window_len > 0) { - /* - * Note: other thread might rollback the ras_next_readahead, - * if it can not get the full size of prepared pages, see the - * end of this function. For stride read ahead, it needs to - * make sure the offset is no less than ras_stride_offset, - * so that stride read ahead can work correctly. - */ - if (stride_io_mode(ras)) - start = max(ras->ras_next_readahead, - ras->ras_stride_offset); - else - start = ras->ras_next_readahead; + if (ras->ras_window_len > 0) end = ras->ras_window_start + ras->ras_window_len - 1; - } + + /* Enlarge the RA window to encompass the full read */ + if (vio->vui_ra_valid && + end < vio->vui_ra_start + vio->vui_ra_count - 1) + end = vio->vui_ra_start + vio->vui_ra_count - 1; if (end != 0) { unsigned long rpc_boundary; @@ -602,7 +597,7 @@ static void ras_reset(struct inode *inode, struct ll_readahead_state *ras, ras->ras_consecutive_pages = 0; ras->ras_window_len = 0; ras_set_start(inode, ras, index); - ras->ras_next_readahead = max(ras->ras_window_start, index); + ras->ras_next_readahead = max(ras->ras_window_start, index + 1); RAS_CDEBUG(ras); } @@ -733,10 +728,11 @@ static void ras_increase_window(struct inode *inode, static void ras_update(struct ll_sb_info *sbi, struct inode *inode, struct ll_readahead_state *ras, unsigned long index, - unsigned int hit) + enum ras_update_flags flags) { struct ll_ra_info *ra = &sbi->ll_ra_info; int zero = 0, stride_detect = 0, ra_miss = 0; + bool hit = flags & LL_RAS_HIT; spin_lock(&ras->ras_lock); @@ -766,7 +762,7 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode, * to for subsequent IO. The mmap case does not increment * ras_requests and thus can never trigger this behavior. */ - if (ras->ras_requests == 2 && !ras->ras_request_index) { + if (ras->ras_requests >= 2 && !ras->ras_request_index) { __u64 kms_pages; kms_pages = (i_size_read(inode) + PAGE_SIZE - 1) >> @@ -778,8 +774,7 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode, if (kms_pages && kms_pages <= ra->ra_max_read_ahead_whole_pages) { ras->ras_window_start = 0; - ras->ras_last_readpage = 0; - ras->ras_next_readahead = 0; + ras->ras_next_readahead = index + 1; ras->ras_window_len = min(ra->ra_max_pages_per_file, ra->ra_max_read_ahead_whole_pages); goto out_unlock; @@ -867,8 +862,13 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode, /* Trigger RA in the mmap case where ras_consecutive_requests * is not incremented and thus can't be used to trigger RA */ - if (!ras->ras_window_len && ras->ras_consecutive_pages == 4) { - ras->ras_window_len = RAS_INCREASE_STEP(inode); + if (ras->ras_consecutive_pages >= 4 && flags & LL_RAS_MMAP) { + ras_increase_window(inode, ras, ra); + /* + * reset consecutive pages so that the readahead window can + * grow gradually. + */ + ras->ras_consecutive_pages = 0; goto out_unlock; } @@ -1101,9 +1101,16 @@ static int ll_io_read_page(const struct lu_env *env, struct cl_io *io, vpg = cl2vvp_page(cl_object_page_slice(page->cp_obj, page)); if (sbi->ll_ra_info.ra_max_pages_per_file > 0 && - sbi->ll_ra_info.ra_max_pages > 0) - ras_update(sbi, inode, ras, vvp_index(vpg), - vpg->vpg_defer_uptodate); + sbi->ll_ra_info.ra_max_pages > 0) { + struct vvp_io *vio = vvp_env_io(env); + enum ras_update_flags flags = 0; + + if (vpg->vpg_defer_uptodate) + flags |= LL_RAS_HIT; + if (!vio->vui_ra_valid) + flags |= LL_RAS_MMAP; + ras_update(sbi, inode, ras, vvp_index(vpg), flags); + } if (vpg->vpg_defer_uptodate) { vpg->vpg_ra_used = 1; -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:11 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:11 -0500 Subject: [lustre-devel] [PATCH 04/22] staging: lustre: osc: handle osc eviction correctly In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-5-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong Cleanup everything if an OSC is being evicted. Group lock is not well supported yet. Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6271 Reviewed-on: http://review.whamcloud.com/14989 Reviewed-by: John L. Hammond Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 3 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 25 ++++---- .../staging/lustre/lustre/osc/osc_cl_internal.h | 11 ++- drivers/staging/lustre/lustre/osc/osc_internal.h | 2 + drivers/staging/lustre/lustre/osc/osc_io.c | 60 +++++++++++++++---- drivers/staging/lustre/lustre/osc/osc_object.c | 19 ++++++ drivers/staging/lustre/lustre/osc/osc_request.c | 42 +++++++++++-- 7 files changed, 124 insertions(+), 38 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index d03e6d4..c1665f9 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1130,8 +1130,7 @@ static int lock_matches(struct ldlm_lock *lock, struct lock_match_data *data) if (!data->lmd_unref && LDLM_HAVE_MASK(lock, GONE)) return INTERVAL_ITER_CONT; - if ((data->lmd_flags & LDLM_FL_LOCAL_ONLY) && - !ldlm_is_local(lock)) + if (!equi(data->lmd_flags & LDLM_FL_LOCAL_ONLY, ldlm_is_local(lock))) return INTERVAL_ITER_CONT; if (data->lmd_flags & LDLM_FL_TEST_LOCK) { diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index b0f030c..76942cc 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -247,7 +247,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, goto out; } - if (ext->oe_dlmlock) { + if (ext->oe_dlmlock && !ldlm_is_failed(ext->oe_dlmlock)) { struct ldlm_extent *extent; extent = &ext->oe_dlmlock->l_policy_data.l_extent; @@ -2710,8 +2710,8 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, /** * Called by osc_io_setattr_start() to freeze and destroy covering extents. */ -int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj, __u64 size) +int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, + u64 size, struct osc_extent **extp) { struct client_obd *cli = osc_cli(obj); struct osc_extent *ext; @@ -2808,9 +2808,11 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, /* we need to hold this extent in OES_TRUNC state so * that no writeback will happen. This is to avoid * BUG 17397. + * Only partial truncate can reach here, if @size is + * not zero, the caller should provide a valid @extp. */ - LASSERT(!oio->oi_trunc); - oio->oi_trunc = osc_extent_get(ext); + LASSERT(!*extp); + *extp = osc_extent_get(ext); OSC_EXTENT_DUMP(D_CACHE, ext, "trunc at %llu\n", size); } @@ -2836,13 +2838,10 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, /** * Called after osc_io_setattr_end to add oio->oi_trunc back to cache. */ -void osc_cache_truncate_end(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj) +void osc_cache_truncate_end(const struct lu_env *env, struct osc_extent *ext) { - struct osc_extent *ext = oio->oi_trunc; - - oio->oi_trunc = NULL; if (ext) { + struct osc_object *obj = ext->oe_obj; bool unplug = false; EASSERT(ext->oe_nr_pages > 0, ext); @@ -3183,8 +3182,10 @@ static int discard_cb(const struct lu_env *env, struct cl_io *io, /* page is top page. */ info->oti_next_index = osc_index(ops) + 1; if (cl_page_own(env, io, page) == 0) { - KLASSERT(ergo(page->cp_type == CPT_CACHEABLE, - !PageDirty(cl_page_vmpage(page)))); + if (!ergo(page->cp_type == CPT_CACHEABLE, + !PageDirty(cl_page_vmpage(page)))) + CL_PAGE_DEBUG(D_ERROR, env, page, + "discard dirty page?\n"); /* discard the page */ cl_page_discard(env, io, page); diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index cce55a9..c09ab97 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -159,6 +159,10 @@ struct osc_object { /* Protect osc_lock this osc_object has */ spinlock_t oo_ol_spin; struct list_head oo_ol_list; + + /** number of active IOs of this object */ + atomic_t oo_nr_ios; + wait_queue_head_t oo_io_waitq; }; static inline void osc_object_lock(struct osc_object *obj) @@ -399,10 +403,9 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, 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); -int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj, __u64 size); -void osc_cache_truncate_end(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj); +int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, + u64 size, struct osc_extent **extp); +void osc_cache_truncate_end(const struct lu_env *env, struct osc_extent *ext); int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, pgoff_t start, pgoff_t end, int hp, int discard); int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 688783d..d9837b7 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -218,4 +218,6 @@ struct ldlm_lock *osc_dlmlock_at_pgoff(const struct lu_env *env, struct osc_object *obj, pgoff_t index, enum osc_dap_flags flags); +int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc); + #endif /* OSC_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 439ba64..369761f 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -329,8 +329,25 @@ static int osc_io_commit_async(const struct lu_env *env, return result; } -static int osc_io_rw_iter_init(const struct lu_env *env, - const struct cl_io_slice *ios) +static int osc_io_iter_init(const struct lu_env *env, + const struct cl_io_slice *ios) +{ + struct osc_object *osc = cl2osc(ios->cis_obj); + struct obd_import *imp = osc_cli(osc)->cl_import; + int rc = -EIO; + + spin_lock(&imp->imp_lock); + if (likely(!imp->imp_invalid)) { + atomic_inc(&osc->oo_nr_ios); + rc = 0; + } + spin_unlock(&imp->imp_lock); + + return rc; +} + +static int osc_io_write_iter_init(const struct lu_env *env, + const struct cl_io_slice *ios) { struct cl_io *io = ios->cis_io; struct osc_io *oio = osc_env_io(env); @@ -341,7 +358,7 @@ static int osc_io_rw_iter_init(const struct lu_env *env, unsigned long max_pages; if (cl_io_is_append(io)) - return 0; + return osc_io_iter_init(env, ios); npages = io->u.ci_rw.crw_count >> PAGE_SHIFT; if (io->u.ci_rw.crw_pos & ~PAGE_MASK) @@ -373,11 +390,21 @@ static int osc_io_rw_iter_init(const struct lu_env *env, (void)ptlrpcd_queue_work(cli->cl_lru_work); } - return 0; + return osc_io_iter_init(env, ios); +} + +static void osc_io_iter_fini(const struct lu_env *env, + const struct cl_io_slice *ios) +{ + struct osc_object *osc = cl2osc(ios->cis_obj); + + LASSERT(atomic_read(&osc->oo_nr_ios) > 0); + if (atomic_dec_and_test(&osc->oo_nr_ios)) + wake_up_all(&osc->oo_io_waitq); } -static void osc_io_rw_iter_fini(const struct lu_env *env, - const struct cl_io_slice *ios) +static void osc_io_write_iter_fini(const struct lu_env *env, + const struct cl_io_slice *ios) { struct osc_io *oio = osc_env_io(env); struct osc_object *osc = cl2osc(ios->cis_obj); @@ -388,6 +415,8 @@ static void osc_io_rw_iter_fini(const struct lu_env *env, oio->oi_lru_reserved = 0; } oio->oi_write_osclock = NULL; + + osc_io_iter_fini(env, ios); } static int osc_io_fault_start(const struct lu_env *env, @@ -478,7 +507,8 @@ static int osc_io_setattr_start(const struct lu_env *env, /* truncate cache dirty pages first */ if (cl_io_is_trunc(io)) - result = osc_cache_truncate_start(env, oio, cl2osc(obj), size); + result = osc_cache_truncate_start(env, cl2osc(obj), size, + &oio->oi_trunc); if (result == 0 && oio->oi_lockless == 0) { cl_object_attr_lock(obj); @@ -588,10 +618,8 @@ static void osc_io_setattr_end(const struct lu_env *env, __u64 size = io->u.ci_setattr.sa_attr.lvb_size; osc_trunc_check(env, io, oio, size); - if (oio->oi_trunc) { - osc_cache_truncate_end(env, oio, cl2osc(obj)); - oio->oi_trunc = NULL; - } + osc_cache_truncate_end(env, oio->oi_trunc); + oio->oi_trunc = NULL; } } @@ -831,17 +859,21 @@ static void osc_io_end(const struct lu_env *env, static const struct cl_io_operations osc_io_ops = { .op = { [CIT_READ] = { + .cio_iter_init = osc_io_iter_init, + .cio_iter_fini = osc_io_iter_fini, .cio_start = osc_io_read_start, .cio_fini = osc_io_fini }, [CIT_WRITE] = { - .cio_iter_init = osc_io_rw_iter_init, - .cio_iter_fini = osc_io_rw_iter_fini, + .cio_iter_init = osc_io_write_iter_init, + .cio_iter_fini = osc_io_write_iter_fini, .cio_start = osc_io_write_start, .cio_end = osc_io_end, .cio_fini = osc_io_fini }, [CIT_SETATTR] = { + .cio_iter_init = osc_io_iter_init, + .cio_iter_fini = osc_io_iter_fini, .cio_start = osc_io_setattr_start, .cio_end = osc_io_setattr_end }, @@ -850,6 +882,8 @@ static void osc_io_end(const struct lu_env *env, .cio_end = osc_io_data_version_end, }, [CIT_FAULT] = { + .cio_iter_init = osc_io_iter_init, + .cio_iter_fini = osc_io_iter_fini, .cio_start = osc_io_fault_start, .cio_end = osc_io_end, .cio_fini = osc_io_fini diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index e0c3324..d3e5ca7 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -78,6 +78,9 @@ static int osc_object_init(const struct lu_env *env, struct lu_object *obj, INIT_LIST_HEAD(&osc->oo_write_item); INIT_LIST_HEAD(&osc->oo_read_item); + atomic_set(&osc->oo_nr_ios, 0); + init_waitqueue_head(&osc->oo_io_waitq); + osc->oo_root.rb_node = NULL; INIT_LIST_HEAD(&osc->oo_hp_exts); INIT_LIST_HEAD(&osc->oo_urgent_exts); @@ -112,6 +115,7 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj) LASSERT(atomic_read(&osc->oo_nr_reads) == 0); LASSERT(atomic_read(&osc->oo_nr_writes) == 0); LASSERT(list_empty(&osc->oo_ol_list)); + LASSERT(!atomic_read(&osc->oo_nr_ios)); lu_object_fini(obj); kmem_cache_free(osc_object_kmem, osc); @@ -444,4 +448,19 @@ struct lu_object *osc_object_alloc(const struct lu_env *env, return obj; } +int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc) +{ + struct l_wait_info lwi = { 0 }; + + CDEBUG(D_INODE, "Invalidate osc object: %p, # of active IOs: %d\n", + osc, atomic_read(&osc->oo_nr_ios)); + + l_wait_event(osc->oo_io_waitq, !atomic_read(&osc->oo_nr_ios), &lwi); + + /* Discard all pages of this object. */ + osc_cache_truncate_start(env, osc, 0, NULL); + + return 0; +} + /** @} osc */ diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 5197768..bc698d3 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2501,6 +2501,33 @@ static int osc_disconnect(struct obd_export *exp) return rc; } +static int osc_ldlm_resource_invalidate(struct cfs_hash *hs, + struct cfs_hash_bd *bd, + struct hlist_node *hnode, void *arg) +{ + struct ldlm_resource *res = cfs_hash_object(hs, hnode); + struct osc_object *osc = NULL; + struct lu_env *env = arg; + struct ldlm_lock *lock; + + lock_res(res); + list_for_each_entry(lock, &res->lr_granted, l_res_link) { + if (lock->l_ast_data && !osc) { + osc = lock->l_ast_data; + cl_object_get(osc2cl(osc)); + } + lock->l_ast_data = NULL; + } + unlock_res(res); + + if (osc) { + osc_object_invalidate(env, osc); + cl_object_put(env, osc2cl(osc)); + } + + return 0; +} + static int osc_import_event(struct obd_device *obd, struct obd_import *imp, enum obd_import_event event) @@ -2528,17 +2555,18 @@ static int osc_import_event(struct obd_device *obd, struct lu_env *env; int refcheck; + ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); + env = cl_env_get(&refcheck); if (!IS_ERR(env)) { - /* Reset grants */ - cli = &obd->u.cli; - /* all pages go to failing rpcs due to the invalid - * import - */ - osc_io_unplug(env, cli, NULL); + osc_io_unplug(env, &obd->u.cli, NULL); - ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); + cfs_hash_for_each_nolock(ns->ns_rs_hash, + osc_ldlm_resource_invalidate, + env, 0); cl_env_put(env, &refcheck); + + ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); } else { rc = PTR_ERR(env); } -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:14 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:14 -0500 Subject: [lustre-devel] [PATCH 07/22] staging: lustre: obdclass: lu_site_purge() to handle purge-all In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-8-git-send-email-jsimmons@infradead.org> From: Alex Zhuravlev if the callers wants to purge all objects, then scanning should start from the first bucket. Signed-off-by: Alex Zhuravlev Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7038 Reviewed-on: http://review.whamcloud.com/18505 Reviewed-by: Mike Pershin Reviewed-by: Faccini Bruno Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/lu_object.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 43868ed..a02aaa3 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -338,7 +338,7 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr) struct cfs_hash_bd bd2; struct list_head dispose; int did_sth; - unsigned int start; + unsigned int start = 0; int count; int bnr; unsigned int i; @@ -351,7 +351,8 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr) * Under LRU list lock, scan LRU list and move unreferenced objects to * the dispose list, removing them from LRU and hash table. */ - start = s->ls_purge_start; + if (nr != ~0) + start = s->ls_purge_start; bnr = (nr == ~0) ? -1 : nr / (int)CFS_HASH_NBKT(s->ls_obj_hash) + 1; again: /* -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:22 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:22 -0500 Subject: [lustre-devel] [PATCH 15/22] staging: lustre: rpc: increase bulk size In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-16-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong To make the ptlrpc be able to size 16MB IO Signed-off-by: Jinshan Xiong Signed-off-by: Gu Zheng Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7990 Reviewed-on: http://review.whamcloud.com/19366 Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_idl.h | 6 +++++- drivers/staging/lustre/lustre/include/lustre_net.h | 8 ++++++-- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index b9f333b..20f55b7 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -1683,8 +1683,12 @@ struct obd_ioobj { __u32 ioo_bufcnt; /* number of niobufs for this object */ }; +/* + * NOTE: IOOBJ_MAX_BRW_BITS defines the _offset_ of the max_brw field in + * ioo_max_brw, NOT the maximum number of bits in PTLRPC_BULK_OPS_BITS. + * That said, ioo_max_brw is a 32-bit field so the limit is also 16 bits. + */ #define IOOBJ_MAX_BRW_BITS 16 -#define IOOBJ_TYPE_MASK ((1U << IOOBJ_MAX_BRW_BITS) - 1) #define ioobj_max_brw_get(ioo) (((ioo)->ioo_max_brw >> IOOBJ_MAX_BRW_BITS) + 1) #define ioobj_max_brw_set(ioo, num) \ do { (ioo)->ioo_max_brw = ((num) - 1) << IOOBJ_MAX_BRW_BITS; } while (0) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 2be135d..411eb0d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -69,13 +69,17 @@ #define PTLRPC_MD_OPTIONS 0 /** - * Max # of bulk operations in one request. + * log2 max # of bulk operations in one request: 2=4MB/RPC, 5=32MB/RPC, ... * In order for the client and server to properly negotiate the maximum * possible transfer size, PTLRPC_BULK_OPS_COUNT must be a power-of-two * value. The client is free to limit the actual RPC size for any bulk * transfer via cl_max_pages_per_rpc to some non-power-of-two value. + * NOTE: This is limited to 16 (=64GB RPCs) by IOOBJ_MAX_BRW_BITS. */ -#define PTLRPC_BULK_OPS_BITS 2 +#define PTLRPC_BULK_OPS_BITS 4 +#if PTLRPC_BULK_OPS_BITS > 16 +#error "More than 65536 BRW RPCs not allowed by IOOBJ_MAX_BRW_BITS." +#endif #define PTLRPC_BULK_OPS_COUNT (1U << PTLRPC_BULK_OPS_BITS) /** * PTLRPC_BULK_OPS_MASK is for the convenience of the client only, and diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index f50f487..e12eb83 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -1576,6 +1576,8 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct obd_ioobj, ioo_bufcnt)); LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt) == 4, "found %lld\n", (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt)); + LASSERTF(IOOBJ_MAX_BRW_BITS == 16, "found %lld\n", + (long long)IOOBJ_MAX_BRW_BITS); /* Checks for union lquota_id */ LASSERTF((int)sizeof(union lquota_id) == 16, "found %lld\n", -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:29 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:29 -0500 Subject: [lustre-devel] [PATCH 22/22] staging: lustre: libcfs: remove lnet upcall code In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-23-git-send-email-jsimmons@infradead.org> From: Alexander Zarochentsev Removing lnet upcall infrastructure completely as nobody uses it anymore. The upcall causes a delay before calling BUG() and might even cause a hang making getting a crash dump unreliable or containing outdated info. Signed-off-by: Alexander Zarochentsev Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8418 Seagate-bug-id: MRP-2939 Reviewed-on: http://review.whamcloud.com/21440 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/include/linux/libcfs/libcfs.h | 1 - .../lustre/include/linux/libcfs/libcfs_private.h | 2 - .../staging/lustre/lnet/libcfs/linux/linux-debug.c | 54 -------------------- drivers/staging/lustre/lnet/libcfs/module.c | 8 --- 4 files changed, 0 insertions(+), 65 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 70eb08e..cc2c0e9 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -125,7 +125,6 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp, /** * The path of debug log dump upcall script. */ -extern char lnet_upcall[1024]; extern char lnet_debug_log_upcall[1024]; extern struct cfs_wi_sched *cfs_sched_rehash; diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index 41a651f..aab15d8 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -169,8 +169,6 @@ #define ntohs(x) ___ntohs(x) #endif -void libcfs_run_upcall(char **argv); -void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msg); void libcfs_debug_dumplog(void); int libcfs_debug_init(unsigned long bufsize); int libcfs_debug_cleanup(void); diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c index d8a9894..39a72e3 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c @@ -57,7 +57,6 @@ #include -char lnet_upcall[1024] = "/usr/lib/lustre/lnet_upcall"; char lnet_debug_log_upcall[1024] = "/usr/lib/lustre/lnet_debug_log_upcall"; /** @@ -92,58 +91,6 @@ void libcfs_run_debug_log_upcall(char *file) } } -void libcfs_run_upcall(char **argv) -{ - int rc; - int argc; - static const char * const envp[] = { - "HOME=/", - "PATH=/sbin:/bin:/usr/sbin:/usr/bin", - NULL - }; - - argv[0] = lnet_upcall; - argc = 1; - while (argv[argc]) - argc++; - - LASSERT(argc >= 2); - - rc = call_usermodehelper(argv[0], argv, (char **)envp, 1); - if (rc < 0 && rc != -ENOENT) { - CERROR("Error %d invoking LNET upcall %s %s%s%s%s%s%s%s%s; check /sys/kernel/debug/lnet/upcall\n", - rc, argv[0], argv[1], - argc < 3 ? "" : ",", argc < 3 ? "" : argv[2], - argc < 4 ? "" : ",", argc < 4 ? "" : argv[3], - argc < 5 ? "" : ",", argc < 5 ? "" : argv[4], - argc < 6 ? "" : ",..."); - } else { - CDEBUG(D_HA, "Invoked LNET upcall %s %s%s%s%s%s%s%s%s\n", - argv[0], argv[1], - argc < 3 ? "" : ",", argc < 3 ? "" : argv[2], - argc < 4 ? "" : ",", argc < 4 ? "" : argv[3], - argc < 5 ? "" : ",", argc < 5 ? "" : argv[4], - argc < 6 ? "" : ",..."); - } -} - -void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msgdata) -{ - char *argv[6]; - char buf[32]; - - snprintf(buf, sizeof(buf), "%d", msgdata->msg_line); - - argv[1] = "LBUG"; - argv[2] = (char *)msgdata->msg_file; - argv[3] = (char *)msgdata->msg_fn; - argv[4] = buf; - argv[5] = NULL; - - libcfs_run_upcall(argv); -} -EXPORT_SYMBOL(libcfs_run_lbug_upcall); - /* coverity[+kill] */ void __noreturn lbug_with_loc(struct libcfs_debug_msg_data *msgdata) { @@ -158,7 +105,6 @@ void __noreturn lbug_with_loc(struct libcfs_debug_msg_data *msgdata) dump_stack(); if (!libcfs_panic_on_lbug) libcfs_debug_dumplog(); - libcfs_run_lbug_upcall(msgdata); if (libcfs_panic_on_lbug) panic("LBUG"); set_task_state(current, TASK_UNINTERRUPTIBLE); diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c index 5884a33..161e042 100644 --- a/drivers/staging/lustre/lnet/libcfs/module.c +++ b/drivers/staging/lustre/lnet/libcfs/module.c @@ -365,14 +365,6 @@ static int proc_cpt_table(struct ctl_table *table, int write, .mode = 0444, .proc_handler = &proc_cpt_table, }, - - { - .procname = "upcall", - .data = lnet_upcall, - .maxlen = sizeof(lnet_upcall), - .mode = 0644, - .proc_handler = &proc_dostring, - }, { .procname = "debug_log_upcall", .data = lnet_debug_log_upcall, -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:20 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:20 -0500 Subject: [lustre-devel] [PATCH 13/22] staging: lustre: statahead: set sai_index_wait with lli_sa_lock held In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-14-git-send-email-jsimmons@infradead.org> From: Fan Yong It is the sponsor thread of the statahead thread to update the sai::sai_index_wait. Originally, it didn't hold the lli_sa_lock when did that. Becuase of out-of-order execution others may miss to wakeup such thread. On the other hand, if the statahead RPC gets failure, it should wakeup the sponsor thread, not the statahead thread. Signed-off-by: Li Xi Signed-off-by: Fan Yong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7828 Reviewed-on: http://review.whamcloud.com/18499 Reviewed-by: Lai Siyao Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/statahead.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index b43955f..4769a22 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -659,8 +659,8 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, struct ll_inode_info *lli = ll_i2info(dir); struct ll_statahead_info *sai = lli->lli_sai; struct sa_entry *entry = (struct sa_entry *)minfo->mi_cbdata; + wait_queue_head_t *waitq = NULL; __u64 handle = 0; - bool wakeup; if (it_disposition(it, DISP_LOOKUP_NEG)) rc = -ENOENT; @@ -693,7 +693,8 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, spin_lock(&lli->lli_sa_lock); if (rc) { - wakeup = __sa_make_ready(sai, entry, rc); + if (__sa_make_ready(sai, entry, rc)) + waitq = &sai->sai_waitq; } else { entry->se_minfo = minfo; entry->se_req = ptlrpc_request_addref(req); @@ -704,13 +705,15 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, * with parent's lock held, for example: unlink. */ entry->se_handle = handle; - wakeup = !sa_has_callback(sai); + if (!sa_has_callback(sai)) + waitq = &sai->sai_thread.t_ctl_waitq; + list_add_tail(&entry->se_list, &sai->sai_interim_entries); } sai->sai_replied++; - if (wakeup) - wake_up(&sai->sai_thread.t_ctl_waitq); + if (waitq) + wake_up(waitq); spin_unlock(&lli->lli_sa_lock); return rc; @@ -1397,10 +1400,10 @@ static int revalidate_statahead_dentry(struct inode *dir, struct dentry **dentryp, bool unplug) { + struct ll_inode_info *lli = ll_i2info(dir); struct sa_entry *entry = NULL; struct l_wait_info lwi = { 0 }; struct ll_dentry_data *ldd; - struct ll_inode_info *lli; int rc = 0; if ((*dentryp)->d_name.name[0] == '.') { @@ -1446,7 +1449,9 @@ static int revalidate_statahead_dentry(struct inode *dir, sa_handle_callback(sai); if (!sa_ready(entry)) { + spin_lock(&lli->lli_sa_lock); sai->sai_index_wait = entry->se_index; + spin_unlock(&lli->lli_sa_lock); lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(30), NULL, LWI_ON_SIGNAL_NOOP, NULL); rc = l_wait_event(sai->sai_waitq, sa_ready(entry), &lwi); @@ -1514,7 +1519,6 @@ static int revalidate_statahead_dentry(struct inode *dir, * dentry_may_statahead(). */ ldd = ll_d2d(*dentryp); - lli = ll_i2info(dir); /* ldd can be NULL if llite lookup failed. */ if (ldd) ldd->lld_sa_generation = lli->lli_sa_generation; -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:26 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:26 -0500 Subject: [lustre-devel] [PATCH 19/22] staging: lustre: llite: ll_dir_ioctl cleanup of redundant comparisons In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-20-git-send-email-jsimmons@infradead.org> From: Parinay Kondekar In ll_dir_ioctl() two identical comparisions are present for return code (rc) of ll_dir_getstripe(). This patch removes the other inside if( ) condition which is not necessary. Signed-off-by: Parinay Kondekar Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6512 Reviewed-on: http://review.whamcloud.com/18027 Reviewed-by: Bobi Jam Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/dir.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 351e900..3dc7344 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1227,9 +1227,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* Get default LMV EA */ if (lum.lum_magic == LMV_USER_MAGIC) { - if (rc) - goto finish_req; - if (lmmsize > sizeof(*ulmv)) { rc = -EINVAL; goto finish_req; -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:10 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:10 -0500 Subject: [lustre-devel] [PATCH 03/22] staging: lustre: mdt: race between open and migrate In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-4-git-send-email-jsimmons@infradead.org> From: wang di During intent open, it was found that if the parent has been migrated to another MDT, it should retry the open request with the new object, so it needs to keep the old object in the orphan list, which will be cleanup during next recovery. Note: if the client still using the old FID after next recovery, it will return -ENOENT for the application. Also enqueue the lease lock of the migrating file, then compare the lease before migration to make sure no other clients open the file at the same time. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6475 Reviewed-on: http://review.whamcloud.com/14497 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre_req_layout.h | 1 + drivers/staging/lustre/lustre/llite/dir.c | 2 +- drivers/staging/lustre/lustre/llite/file.c | 76 ++++++++++++++++--- .../staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 59 +++++++++------- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 20 +++++- drivers/staging/lustre/lustre/ptlrpc/layout.c | 18 +++++ 7 files changed, 138 insertions(+), 40 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/drivers/staging/lustre/lustre/include/lustre_req_layout.h index 7657132..fbcd395 100644 --- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h +++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h @@ -167,6 +167,7 @@ void req_capsule_shrink(struct req_capsule *pill, extern struct req_format RQF_MDS_REINT_SETXATTR; extern struct req_format RQF_MDS_QUOTACTL; extern struct req_format RQF_MDS_SWAP_LAYOUTS; +extern struct req_format RQF_MDS_REINT_MIGRATE; /* MDS hsm formats */ extern struct req_format RQF_MDS_HSM_STATE_GET; extern struct req_format RQF_MDS_HSM_STATE_SET; diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index ce05493..351e900 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1083,7 +1083,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) goto out_free; } - rc = ll_get_fid_by_name(inode, filename, namelen, NULL); + rc = ll_get_fid_by_name(inode, filename, namelen, NULL, NULL); if (rc < 0) { CERROR("%s: lookup %.*s failed: rc = %d\n", ll_get_fsname(inode->i_sb, NULL, 0), namelen, diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index ea21e19..aa29583 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2531,7 +2531,8 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) } int ll_get_fid_by_name(struct inode *parent, const char *name, - int namelen, struct lu_fid *fid) + int namelen, struct lu_fid *fid, + struct inode **inode) { struct md_op_data *op_data = NULL; struct ptlrpc_request *req; @@ -2543,7 +2544,7 @@ int ll_get_fid_by_name(struct inode *parent, const char *name, if (IS_ERR(op_data)) return PTR_ERR(op_data); - op_data->op_valid = OBD_MD_FLID; + op_data->op_valid = OBD_MD_FLID | OBD_MD_FLTYPE; rc = md_getattr_name(ll_i2sbi(parent)->ll_md_exp, op_data, &req); ll_finish_md_op_data(op_data); if (rc < 0) @@ -2556,6 +2557,9 @@ int ll_get_fid_by_name(struct inode *parent, const char *name, } if (fid) *fid = body->mbo_fid1; + + if (inode) + rc = ll_prep_inode(inode, req, parent->i_sb, NULL); out_req: ptlrpc_req_finished(req); return rc; @@ -2565,9 +2569,12 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, const char *name, int namelen) { struct ptlrpc_request *request = NULL; + struct obd_client_handle *och = NULL; struct inode *child_inode = NULL; struct dentry *dchild = NULL; struct md_op_data *op_data; + struct mdt_body *body; + u64 data_version = 0; struct qstr qstr; int rc; @@ -2586,22 +2593,25 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, dchild = d_lookup(file_dentry(file), &qstr); if (dchild) { op_data->op_fid3 = *ll_inode2fid(dchild->d_inode); - if (dchild->d_inode) { + if (dchild->d_inode) child_inode = igrab(dchild->d_inode); - if (child_inode) { - inode_lock(child_inode); - op_data->op_fid3 = *ll_inode2fid(child_inode); - ll_invalidate_aliases(child_inode); - } - } dput(dchild); - } else { + } + + if (!child_inode) { rc = ll_get_fid_by_name(parent, name, namelen, - &op_data->op_fid3); + &op_data->op_fid3, &child_inode); if (rc) goto out_free; } + if (!child_inode) { + rc = -EINVAL; + goto out_free; + } + + inode_lock(child_inode); + op_data->op_fid3 = *ll_inode2fid(child_inode); if (!fid_is_sane(&op_data->op_fid3)) { CERROR("%s: migrate %s, but fid "DFID" is insane\n", ll_get_fsname(parent->i_sb, NULL, 0), name, @@ -2620,6 +2630,26 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, rc = 0; goto out_free; } +again: + if (S_ISREG(child_inode->i_mode)) { + och = ll_lease_open(child_inode, NULL, FMODE_WRITE, 0); + if (IS_ERR(och)) { + rc = PTR_ERR(och); + och = NULL; + goto out_free; + } + + rc = ll_data_version(child_inode, &data_version, + LL_DV_WR_FLUSH); + if (rc) + goto out_free; + + op_data->op_handle = och->och_fh; + op_data->op_data = och->och_mod; + op_data->op_data_version = data_version; + op_data->op_lease_handle = och->och_lease_handle; + op_data->op_bias |= MDS_RENAME_MIGRATE; + } op_data->op_mds = mdtidx; op_data->op_cli_flags = CLI_MIGRATE; @@ -2628,10 +2658,32 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, if (!rc) ll_update_times(request, parent); - ptlrpc_req_finished(request); + body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); + if (!body) { + rc = -EPROTO; + goto out_free; + } + + /* + * If the server does release layout lock, then we cleanup + * the client och here, otherwise release it in out_free: + */ + if (och && body->mbo_valid & OBD_MD_CLOSE_INTENT_EXECED) { + obd_mod_put(och->och_mod); + md_clear_open_replay_data(ll_i2sbi(parent)->ll_md_exp, och); + och->och_fh.cookie = DEAD_HANDLE_MAGIC; + kfree(och); + och = NULL; + } + ptlrpc_req_finished(request); + /* Try again if the file layout has changed. */ + if (rc == -EAGAIN && S_ISREG(child_inode->i_mode)) + goto again; out_free: if (child_inode) { + if (och) /* close the file */ + ll_lease_close(och, child_inode, NULL); clear_nlink(child_inode); inode_unlock(child_inode); iput(child_inode); diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index ac4ce05..ae0bb09 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -745,7 +745,7 @@ enum ldlm_mode ll_take_md_lock(struct inode *inode, __u64 bits, int ll_migrate(struct inode *parent, struct file *file, int mdtidx, const char *name, int namelen); int ll_get_fid_by_name(struct inode *parent, const char *name, - int namelen, struct lu_fid *fid); + int namelen, struct lu_fid *fid, struct inode **inode); int ll_inode_permission(struct inode *inode, int mask); int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index c1990f0..f35e1f9 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -376,6 +376,31 @@ void mdc_link_pack(struct ptlrpc_request *req, struct md_op_data *op_data) mdc_pack_name(req, &RMF_NAME, op_data->op_name, op_data->op_namelen); } +static void mdc_intent_close_pack(struct ptlrpc_request *req, + struct md_op_data *op_data) +{ + enum mds_op_bias bias = op_data->op_bias; + struct close_data *data; + struct ldlm_lock *lock; + + if (!(bias & (MDS_HSM_RELEASE | MDS_CLOSE_LAYOUT_SWAP | + MDS_RENAME_MIGRATE))) + return; + + data = req_capsule_client_get(&req->rq_pill, &RMF_CLOSE_DATA); + LASSERT(data); + + lock = ldlm_handle2lock(&op_data->op_lease_handle); + if (lock) { + data->cd_handle = lock->l_remote_handle; + LDLM_LOCK_PUT(lock); + } + ldlm_cli_cancel(&op_data->op_lease_handle, LCF_LOCAL); + + data->cd_data_version = op_data->op_data_version; + data->cd_fid = op_data->op_fid2; +} + void mdc_rename_pack(struct ptlrpc_request *req, struct md_op_data *op_data, const char *old, size_t oldlen, const char *new, size_t newlen) @@ -404,6 +429,15 @@ void mdc_rename_pack(struct ptlrpc_request *req, struct md_op_data *op_data, if (new) mdc_pack_name(req, &RMF_SYMTGT, new, newlen); + + if (op_data->op_cli_flags & CLI_MIGRATE && + op_data->op_bias & MDS_RENAME_MIGRATE) { + struct mdt_ioepoch *epoch; + + mdc_intent_close_pack(req, op_data); + epoch = req_capsule_client_get(&req->rq_pill, &RMF_MDT_EPOCH); + mdc_ioepoch_pack(epoch, op_data); + } } void mdc_getattr_pack(struct ptlrpc_request *req, __u64 valid, u32 flags, @@ -430,31 +464,6 @@ void mdc_getattr_pack(struct ptlrpc_request *req, __u64 valid, u32 flags, op_data->op_namelen); } -static void mdc_intent_close_pack(struct ptlrpc_request *req, - struct md_op_data *op_data) -{ - enum mds_op_bias bias = op_data->op_bias; - struct close_data *data; - struct ldlm_lock *lock; - - if (!(bias & (MDS_HSM_RELEASE | MDS_CLOSE_LAYOUT_SWAP | - MDS_RENAME_MIGRATE))) - return; - - data = req_capsule_client_get(&req->rq_pill, &RMF_CLOSE_DATA); - LASSERT(data); - - lock = ldlm_handle2lock(&op_data->op_lease_handle); - if (lock) { - data->cd_handle = lock->l_remote_handle; - LDLM_LOCK_PUT(lock); - } - ldlm_cli_cancel(&op_data->op_lease_handle, LCF_LOCAL); - - data->cd_data_version = op_data->op_data_version; - data->cd_fid = op_data->op_fid2; -} - void mdc_close_pack(struct ptlrpc_request *req, struct md_op_data *op_data) { struct mdt_ioepoch *epoch; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 5119588..07b1684 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -366,7 +366,8 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, MDS_INODELOCK_FULL); req = ptlrpc_request_alloc(class_exp2cliimp(exp), - &RQF_MDS_REINT_RENAME); + op_data->op_cli_flags & CLI_MIGRATE ? + &RQF_MDS_REINT_MIGRATE : &RQF_MDS_REINT_RENAME); if (!req) { ldlm_lock_list_put(&cancels, l_bl_ast, count); return -ENOMEM; @@ -382,6 +383,23 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, return rc; } + if (op_data->op_cli_flags & CLI_MIGRATE && op_data->op_data) { + struct md_open_data *mod = op_data->op_data; + + LASSERTF(mod->mod_open_req && + mod->mod_open_req->rq_type != LI_POISON, + "POISONED open %p!\n", mod->mod_open_req); + + DEBUG_REQ(D_HA, mod->mod_open_req, "matched open"); + /* + * We no longer want to preserve this open for replay even + * though the open was committed. b=3632, b=3633 + */ + spin_lock(&mod->mod_open_req->rq_lock); + mod->mod_open_req->rq_replay = 0; + spin_unlock(&mod->mod_open_req->rq_lock); + } + if (exp_connect_cancelset(exp) && req) ldlm_cli_cancel_list(&cancels, count, req, 0); diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index 31aa58e..fd976f9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -257,6 +257,18 @@ &RMF_DLM_REQ }; +static const struct req_msg_field *mds_reint_migrate_client[] = { + &RMF_PTLRPC_BODY, + &RMF_REC_REINT, + &RMF_CAPA1, + &RMF_CAPA2, + &RMF_NAME, + &RMF_SYMTGT, + &RMF_DLM_REQ, + &RMF_MDT_EPOCH, + &RMF_CLOSE_DATA +}; + static const struct req_msg_field *mds_last_unlink_server[] = { &RMF_PTLRPC_BODY, &RMF_MDT_BODY, @@ -678,6 +690,7 @@ &RQF_MDS_REINT_UNLINK, &RQF_MDS_REINT_LINK, &RQF_MDS_REINT_RENAME, + &RQF_MDS_REINT_MIGRATE, &RQF_MDS_REINT_SETATTR, &RQF_MDS_REINT_SETXATTR, &RQF_MDS_QUOTACTL, @@ -1254,6 +1267,11 @@ struct req_format RQF_MDS_REINT_RENAME = mds_last_unlink_server); EXPORT_SYMBOL(RQF_MDS_REINT_RENAME); +struct req_format RQF_MDS_REINT_MIGRATE = + DEFINE_REQ_FMT0("MDS_REINT_MIGRATE", mds_reint_migrate_client, + mds_last_unlink_server); +EXPORT_SYMBOL(RQF_MDS_REINT_MIGRATE); + struct req_format RQF_MDS_REINT_SETATTR = DEFINE_REQ_FMT0("MDS_REINT_SETATTR", mds_reint_setattr_client, mds_setattr_server); -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:09 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:09 -0500 Subject: [lustre-devel] [PATCH 02/22] staging: lustre: osc: fix debug log message formatting In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-3-git-send-email-jsimmons@infradead.org> From: Ashish Purkar Corrected newline specifier in debug log message. Signed-off-by: Ashish Purkar Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7029 Reviewed-on: http://review.whamcloud.com/16046 Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/osc_page.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index a80a847..c5129d1 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -462,7 +462,7 @@ static void osc_lru_del(struct client_obd *cli, struct osc_page *opg) * stealing one of them. */ if (osc_cache_too_much(cli)) { - CDEBUG(D_CACHE, "%s: queue LRU workn", cli_name(cli)); + CDEBUG(D_CACHE, "%s: queue LRU work\n", cli_name(cli)); (void)ptlrpcd_queue_work(cli->cl_lru_work); } wake_up(&osc_lru_waitq); -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:13 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:13 -0500 Subject: [lustre-devel] [PATCH 06/22] staging: lustre: llog: reset llog bitmap In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-7-git-send-email-jsimmons@infradead.org> From: wang di Once update request fails due to eviction or other failures, all of update request in the sending list should return fail, because after the failure, the update log in the following request will have wrong llog bitmap. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7039 Reviewed-on: http://review.whamcloud.com/16969 Reviewed-by: Alex Zhuravlev Reviewed-by: James Simmons Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/llog.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index ae63047..65e6ce6 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -114,6 +114,7 @@ static int llog_read_header(const struct lu_env *env, rc = lop->lop_read_header(env, handle); if (rc == LLOG_EEMPTY) { struct llog_log_hdr *llh = handle->lgh_hdr; + size_t len; /* lrh_len should be initialized in llog_init_handle */ handle->lgh_last_idx = 0; /* header is record with index 0 */ @@ -127,6 +128,12 @@ static int llog_read_header(const struct lu_env *env, memcpy(&llh->llh_tgtuuid, uuid, sizeof(llh->llh_tgtuuid)); llh->llh_bitmap_offset = offsetof(typeof(*llh), llh_bitmap); + /* + * Since update llog header might also call this function, + * let's reset the bitmap to 0 here + */ + len = llh->llh_hdr.lrh_len - llh->llh_bitmap_offset; + memset(LLOG_HDR_BITMAP(llh), 0, len - sizeof(llh->llh_tail)); ext2_set_bit(0, LLOG_HDR_BITMAP(llh)); LLOG_HDR_TAIL(llh)->lrt_len = llh->llh_hdr.lrh_len; LLOG_HDR_TAIL(llh)->lrt_index = llh->llh_hdr.lrh_index; -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:25 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:25 -0500 Subject: [lustre-devel] [PATCH 18/22] staging: lustre: import: don't reconnect during connect interpret In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-19-git-send-email-jsimmons@infradead.org> From: Mikhal Pershin The import connect flags might be cleared by ptlrpc_connect_import() wrongly if there is still connect interpret function is running. Use imp_connected boolean variable to indicate that we are still interpretting connect reply and don't try to reconnect until it ends. Signed-off-by: Mikhal Pershin Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7558 Reviewed-on: http://review.whamcloud.com/19312 Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lustre_import.h | 4 +++- drivers/staging/lustre/lustre/ptlrpc/import.c | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 4499c69..f0c931c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -299,7 +299,9 @@ struct obd_import { */ imp_force_reconnect:1, /* import has tried to connect with server */ - imp_connect_tried:1; + imp_connect_tried:1, + /* connected but not FULL yet */ + imp_connected:1; __u32 imp_connect_op; struct obd_connect_data imp_connect_data; __u64 imp_connect_flags_orig; diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 66f5b49..e828019 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -622,7 +622,8 @@ int ptlrpc_connect_import(struct obd_import *imp) spin_unlock(&imp->imp_lock); CERROR("already connected\n"); return 0; - } else if (imp->imp_state == LUSTRE_IMP_CONNECTING) { + } else if (imp->imp_state == LUSTRE_IMP_CONNECTING || + imp->imp_connected) { spin_unlock(&imp->imp_lock); CERROR("already connecting\n"); return -EALREADY; @@ -971,6 +972,13 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, ptlrpc_maybe_ping_import_soon(imp); goto out; } + + /* + * LU-7558: indicate that we are interpretting connect reply, + * pltrpc_connect_import() will not try to reconnect until + * interpret will finish. + */ + imp->imp_connected = 1; spin_unlock(&imp->imp_lock); LASSERT(imp->imp_conn_current); @@ -1194,12 +1202,18 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid); ptlrpc_connect_import(imp); + spin_lock(&imp->imp_lock); + imp->imp_connected = 0; imp->imp_connect_tried = 1; + spin_unlock(&imp->imp_lock); return 0; } out: + spin_lock(&imp->imp_lock); + imp->imp_connected = 0; imp->imp_connect_tried = 1; + spin_unlock(&imp->imp_lock); if (rc != 0) { IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON); -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:21 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:21 -0500 Subject: [lustre-devel] [PATCH 14/22] staging: lustre: obd: add callback for llog_cat_process_or_fork In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-15-git-send-email-jsimmons@infradead.org> From: Alexander Boyko Currently llog_process_or_fork() is hard coded to always pass the function pointer llog_cat_process_cb(). Change llog_cat_process_or_fork() to pass in any function pointer which will allow us more options for llog_cat callback routines in the future. Signed-off-by: Alexander Boyko Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7156 Seagate-bug-id: MRP-2383 Reviewed-on: http://review.whamcloud.com/16416 Reviewed-by: Andreas Dilger Reviewed-by: Nathaniel Clark Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/llog_cat.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index ce8e2f6..de9d01d 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -188,7 +188,8 @@ static int llog_cat_process_cb(const struct lu_env *env, static int llog_cat_process_or_fork(const struct lu_env *env, struct llog_handle *cat_llh, - llog_cb_t cb, void *data, int startcat, + llog_cb_t cat_cb, llog_cb_t cb, + void *data, int startcat, int startidx, bool fork) { struct llog_process_data d; @@ -209,18 +210,15 @@ static int llog_cat_process_or_fork(const struct lu_env *env, cd.lpcd_first_idx = llh->llh_cat_idx; cd.lpcd_last_idx = 0; - rc = llog_process_or_fork(env, cat_llh, llog_cat_process_cb, - &d, &cd, fork); + rc = llog_process_or_fork(env, cat_llh, cat_cb, &d, &cd, fork); if (rc != 0) return rc; cd.lpcd_first_idx = 0; cd.lpcd_last_idx = cat_llh->lgh_last_idx; - rc = llog_process_or_fork(env, cat_llh, llog_cat_process_cb, - &d, &cd, fork); + rc = llog_process_or_fork(env, cat_llh, cat_cb, &d, &cd, fork); } else { - rc = llog_process_or_fork(env, cat_llh, llog_cat_process_cb, - &d, NULL, fork); + rc = llog_process_or_fork(env, cat_llh, cat_cb, &d, NULL, fork); } return rc; @@ -229,7 +227,7 @@ static int llog_cat_process_or_fork(const struct lu_env *env, int llog_cat_process(const struct lu_env *env, struct llog_handle *cat_llh, llog_cb_t cb, void *data, int startcat, int startidx) { - return llog_cat_process_or_fork(env, cat_llh, cb, data, startcat, - startidx, false); + return llog_cat_process_or_fork(env, cat_llh, llog_cat_process_cb, cb, + data, startcat, startidx, false); } EXPORT_SYMBOL(llog_cat_process); -- 1.7.1 From jsimmons at infradead.org Sat Dec 3 00:53:28 2016 From: jsimmons at infradead.org (James Simmons) Date: Fri, 2 Dec 2016 19:53:28 -0500 Subject: [lustre-devel] [PATCH 21/22] staging: lustre: remove set but unused variables In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <1480726409-20350-22-git-send-email-jsimmons@infradead.org> From: Yang Sheng Remove set but unused variables in nidstring.c and osc_request.c as reported by make W=1. Signed-off-by: Yang Sheng Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8378 Reviewed-on: http://review.whamcloud.com/23221 Reviewed-by: Bob Glossman Reviewed-by: Emoly Liu Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lnet/lnet/nidstrings.c | 2 -- drivers/staging/lustre/lustre/osc/osc_request.c | 3 +-- 2 files changed, 1 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c index e1f1ca8..a9fe3e6 100644 --- a/drivers/staging/lustre/lnet/lnet/nidstrings.c +++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c @@ -247,10 +247,8 @@ struct addrrange { { struct cfs_lstr addrrange; struct cfs_lstr net; - struct cfs_lstr tmp; struct nidrange *nr; - tmp = *src; if (!cfs_gettok(src, '@', &addrrange)) goto failed; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 0977127..0c50225 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -933,7 +933,6 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count, 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); @@ -975,7 +974,7 @@ static u32 osc_checksum_bulk(int nob, u32 pg_count, } bufsize = sizeof(cksum); - err = cfs_crypto_hash_final(hdesc, (unsigned char *)&cksum, &bufsize); + cfs_crypto_hash_final(hdesc, (unsigned char *)&cksum, &bufsize); /* For sending we only compute the wrong checksum instead * of corrupting the data so it is still correct on a redo -- 1.7.1 From gregkh at linuxfoundation.org Sat Dec 3 08:55:50 2016 From: gregkh at linuxfoundation.org (gregkh at linuxfoundation.org) Date: Sat, 3 Dec 2016 09:55:50 +0100 Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> Message-ID: <20161203085550.GA5375@kroah.com> On Fri, Dec 02, 2016 at 09:53:08PM +0000, Dilger, Andreas wrote: > Al, > Greg recently raised the issue of what still needs to be done to > move the Lustre code out of staging/ and into the fs/ tree. > > James has been doing a great job of cleaning up various checkpatch > issues and keeping the code updated with the latest fixes, but we > were wondering what you were aware of that needed to be cleaned > up in Lustre? Is the whole "mixing kernel structures in userspace structures" all resolved now? For some reason I thought that you had kernel locks being passed to userspace and then back into the kernel, but it's been a long time since I last looked... If you feel you are ready for a "real" review, I'll be glad to go over the code before the vfs people look at it, just let me know. No need to bother them if you still have basic things wrong that I can find... thanks, greg k-h From lkp at intel.com Sat Dec 3 13:27:31 2016 From: lkp at intel.com (kbuild test robot) Date: Sat, 3 Dec 2016 21:27:31 +0800 Subject: [lustre-devel] [PATCH 3/6] staging: lustre: obdclass: Create a header for obdo related functions In-Reply-To: <1480707650-24089-4-git-send-email-jsimmons@infradead.org> Message-ID: <201612032108.E93gbaZn%fengguang.wu@intel.com> Hi Ben, [auto build test ERROR on staging/staging-testing] [also build test ERROR on next-20161202] [cannot apply to v4.9-rc7] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/James-Simmons/Fix-ups-to-make-lustre_idl-h-a-proper-UAPI-header/20161203-112301 config: s390-allmodconfig (attached as .config) compiler: s390x-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705 reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=s390 Note: the linux-review/James-Simmons/Fix-ups-to-make-lustre_idl-h-a-proper-UAPI-header/20161203-112301 HEAD c2346c2b941862f21c17e2c11dfd2ed0e66f72ea builds fine. It only hurts bisectibility. All errors (new ones prefixed by >>): drivers/staging/lustre/lustre/osc/osc_request.c: In function 'osc_pack_req_body': >> drivers/staging/lustre/lustre/osc/osc_request.c:114:2: error: implicit declaration of function 'lustre_set_wire_obdo' [-Werror=implicit-function-declaration] lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa); ^~~~~~~~~~~~~~~~~~~~ drivers/staging/lustre/lustre/osc/osc_request.c: In function 'osc_getattr': >> drivers/staging/lustre/lustre/osc/osc_request.c:149:2: error: implicit declaration of function 'lustre_get_wire_obdo' [-Werror=implicit-function-declaration] lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oa, ^~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors vim +/lustre_set_wire_obdo +114 drivers/staging/lustre/lustre/osc/osc_request.c d7e09d039 Peng Tao 2013-05-02 108 { d7e09d039 Peng Tao 2013-05-02 109 struct ost_body *body; d7e09d039 Peng Tao 2013-05-02 110 d7e09d039 Peng Tao 2013-05-02 111 body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY); d7e09d039 Peng Tao 2013-05-02 112 LASSERT(body); d7e09d039 Peng Tao 2013-05-02 113 48a2a12af John L. Hammond 2016-10-02 @114 lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa); d7e09d039 Peng Tao 2013-05-02 115 } d7e09d039 Peng Tao 2013-05-02 116 d7e09d039 Peng Tao 2013-05-02 117 static int osc_getattr(const struct lu_env *env, struct obd_export *exp, 48a2a12af John L. Hammond 2016-10-02 118 struct obdo *oa) d7e09d039 Peng Tao 2013-05-02 119 { d7e09d039 Peng Tao 2013-05-02 120 struct ptlrpc_request *req; d7e09d039 Peng Tao 2013-05-02 121 struct ost_body *body; d7e09d039 Peng Tao 2013-05-02 122 int rc; d7e09d039 Peng Tao 2013-05-02 123 d7e09d039 Peng Tao 2013-05-02 124 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); 7f1ae4c06 Oleg Drokin 2016-02-16 125 if (!req) 0a3bdb007 Greg Kroah-Hartman 2013-08-03 126 return -ENOMEM; d7e09d039 Peng Tao 2013-05-02 127 d7e09d039 Peng Tao 2013-05-02 128 rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); d7e09d039 Peng Tao 2013-05-02 129 if (rc) { d7e09d039 Peng Tao 2013-05-02 130 ptlrpc_request_free(req); 0a3bdb007 Greg Kroah-Hartman 2013-08-03 131 return rc; d7e09d039 Peng Tao 2013-05-02 132 } d7e09d039 Peng Tao 2013-05-02 133 48a2a12af John L. Hammond 2016-10-02 134 osc_pack_req_body(req, oa); d7e09d039 Peng Tao 2013-05-02 135 d7e09d039 Peng Tao 2013-05-02 136 ptlrpc_request_set_replen(req); d7e09d039 Peng Tao 2013-05-02 137 d7e09d039 Peng Tao 2013-05-02 138 rc = ptlrpc_queue_wait(req); d7e09d039 Peng Tao 2013-05-02 139 if (rc) 26c4ea46a Tina Johnson 2014-09-21 140 goto out; d7e09d039 Peng Tao 2013-05-02 141 d7e09d039 Peng Tao 2013-05-02 142 body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); 7f1ae4c06 Oleg Drokin 2016-02-16 143 if (!body) { 26c4ea46a Tina Johnson 2014-09-21 144 rc = -EPROTO; 26c4ea46a Tina Johnson 2014-09-21 145 goto out; 26c4ea46a Tina Johnson 2014-09-21 146 } d7e09d039 Peng Tao 2013-05-02 147 d7e09d039 Peng Tao 2013-05-02 148 CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode); 48a2a12af John L. Hammond 2016-10-02 @149 lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oa, 3b2f75fd5 wang di 2013-06-03 150 &body->oa); d7e09d039 Peng Tao 2013-05-02 151 48a2a12af John L. Hammond 2016-10-02 152 oa->o_blksize = cli_brw_size(exp->exp_obd); :::::: The code at line 114 was first introduced by commit :::::: 48a2a12afc54aa1ebfdb1e821fc3dc7893816986 staging: lustre: osc: remove remaining bits for capa support :::::: TO: John L. Hammond :::::: CC: Greg Kroah-Hartman --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation -------------- next part -------------- A non-text attachment was scrubbed... Name: .config.gz Type: application/gzip Size: 43289 bytes Desc: not available URL: From dan.carpenter at oracle.com Mon Dec 5 11:09:56 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 5 Dec 2016 14:09:56 +0300 Subject: [lustre-devel] [patch] staging: lustre: cl_page: fix a typo in comments Message-ID: <20161205110955.GA19260@elgon.mountain> We want to "sever" all the ways to get a new pointer to "pg". Signed-off-by: Dan Carpenter diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index bdc0aa5846ef..cd9a40ca4448 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -667,7 +667,7 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg) PASSERT(env, pg, pg->cp_state != CPS_FREEING); /* - * Severe all ways to obtain new pointers to @pg. + * Sever all ways to obtain new pointers to @pg. */ cl_page_owner_clear(pg); From dan.carpenter at oracle.com Mon Dec 5 20:50:05 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 5 Dec 2016 23:50:05 +0300 Subject: [lustre-devel] [PATCH 3/6] staging: lustre: obdclass: Create a header for obdo related functions In-Reply-To: <1480707650-24089-4-git-send-email-jsimmons@infradead.org> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> <1480707650-24089-4-git-send-email-jsimmons@infradead.org> Message-ID: <20161205205005.GA31243@mwanda> On Fri, Dec 02, 2016 at 02:40:47PM -0500, James Simmons wrote: > - __u32 local_flags = 0; > + u32 local_flags = 0; > - if (local_flags != 0) { > + if (local_flags) { Please avoid these unrelated white space changes. regards, dan carpenter From dan.carpenter at oracle.com Mon Dec 5 20:52:00 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 5 Dec 2016 23:52:00 +0300 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <20161202173332.5100-1-lambert.quentin@gmail.com> References: <20161202173332.5100-1-lambert.quentin@gmail.com> Message-ID: <20161205205200.GB31243@mwanda> On Fri, Dec 02, 2016 at 06:33:32PM +0100, Quentin Lambert wrote: > lnet_ipif_enumerate was assigning a pointer from kernel space to user > space. This patch uses copy_to_user to properly do that assignment. Put the exact warning message here. > > Signed-off-by: Quentin Lambert > --- > shouldn't we be using ifc_req instead of ifc_buf? > > drivers/staging/lustre/lnet/lnet/lib-socket.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c > @@ -181,7 +181,13 @@ lnet_ipif_enumerate(char ***namesp) > goto out0; > } > > - ifc.ifc_buf = (char *)ifr; > + rc = copy_to_user(ifc.ifc_buf, (char *)ifr, > + nalloc * sizeof(*ifr)); > + if (rc) { > + rc = -ENOMEM; > + goto out1; > + } No idea what's going on here. The original code is correct. regards, dan carpenter From dan.carpenter at oracle.com Mon Dec 5 20:54:36 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 5 Dec 2016 23:54:36 +0300 Subject: [lustre-devel] [PATCH 5/6] staging: lustre: headers: Move functions out of lustre_idl.h In-Reply-To: <1480707650-24089-6-git-send-email-jsimmons@infradead.org> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> <1480707650-24089-6-git-send-email-jsimmons@infradead.org> Message-ID: <20161205205435.GD31243@mwanda> On Fri, Dec 02, 2016 at 02:40:49PM -0500, James Simmons wrote: > -/* If LDLM_ENQUEUE, 1 slot is already occupied, 1 is available. > - * Otherwise, 2 are available. > - */ > -#define ldlm_request_bufsize(count, type) \ > -({ \ > - int _avail = LDLM_LOCKREQ_HANDLES; \ > - _avail -= (type == LDLM_ENQUEUE ? LDLM_ENQUEUE_CANCEL_OFF : 0); \ > - sizeof(struct ldlm_request) + \ > - (count > _avail ? count - _avail : 0) * \ > - sizeof(struct lustre_handle); \ > -}) > - > +/** > + * ldlm_request_bufsize > + * > + * @count: number of ldlm handles > + * @type: ldlm opcode > + * > + * If opcode=LDLM_ENQUEUE, 1 slot is already occupied, > + * LDLM_LOCKREQ_HANDLE -1 slots are available. > + * Otherwise, LDLM_LOCKREQ_HANDLE slots are available. > + * > + * Return: size of the request buffer > + */ > +int ldlm_request_bufsize(int count, int type) > +{ > + int avail = LDLM_LOCKREQ_HANDLES; > + > + if (type == LDLM_ENQUEUE) > + avail -= LDLM_ENQUEUE_CANCEL_OFF; > + > + if (count > avail) > + avail = (count - avail) * sizeof(struct lustre_handle); > + else > + avail = 0; > + > + return sizeof(struct ldlm_request) + avail; > +} > + This is a nice cleanup. regards, dan carpenter From dan.carpenter at oracle.com Mon Dec 5 20:55:37 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 5 Dec 2016 23:55:37 +0300 Subject: [lustre-devel] [PATCH 04/22] staging: lustre: osc: handle osc eviction correctly In-Reply-To: <1480726409-20350-5-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> <1480726409-20350-5-git-send-email-jsimmons@infradead.org> Message-ID: <20161205205537.GB31465@mwanda> On Fri, Dec 02, 2016 at 07:53:11PM -0500, James Simmons wrote: > @@ -3183,8 +3182,10 @@ static int discard_cb(const struct lu_env *env, struct cl_io *io, > /* page is top page. */ > info->oti_next_index = osc_index(ops) + 1; > if (cl_page_own(env, io, page) == 0) { > - KLASSERT(ergo(page->cp_type == CPT_CACHEABLE, > - !PageDirty(cl_page_vmpage(page)))); > + if (!ergo(page->cp_type == CPT_CACHEABLE, > + !PageDirty(cl_page_vmpage(page)))) > + CL_PAGE_DEBUG(D_ERROR, env, page, > + "discard dirty page?\n"); I don't understand the point of the ergo macro. There are way too many double negatives (some of them hidden for my small brain). How is that simpler than just writing it out: if (page->cp_type == CPT_CACHEABLE && PageDirty(cl_page_vmpage(page)) CL_PAGE_DEBUG(D_ERROR, env, page, "discard dirty page?\n"); regards, dan carpenter From dan.carpenter at oracle.com Mon Dec 5 20:57:15 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 5 Dec 2016 23:57:15 +0300 Subject: [lustre-devel] [PATCH 05/22] staging: lustre: lmv: remove nlink check in lmv_revalidate_slaves In-Reply-To: <1480726409-20350-6-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> <1480726409-20350-6-git-send-email-jsimmons@infradead.org> Message-ID: <20161205205715.GC31465@mwanda> On Fri, Dec 02, 2016 at 07:53:12PM -0500, James Simmons wrote: > From: wang di > > Remove nlink < 2 check in lmv_revalidate_slaves, because > after nlink reaches to LDISKFS_LINK_MAX (65000), the inode > nlink will be set to 1. > I don't understand how this changelog matches the patch... The changelog says we're removing a check but really this is a NULL dereference fix, right? We're not really removing a check at all, just changing it for something else. We do remove a printk, though. regards, dan carpenter From andreas.dilger at intel.com Mon Dec 5 21:55:04 2016 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Mon, 5 Dec 2016 21:55:04 +0000 Subject: [lustre-devel] [PATCH 3/6] staging: lustre: obdclass: Create a header for obdo related functions In-Reply-To: <20161205205005.GA31243@mwanda> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> <1480707650-24089-4-git-send-email-jsimmons@infradead.org> <20161205205005.GA31243@mwanda> Message-ID: <2394CAB0-41C1-4F3B-AF94-03D302F6ABF5@intel.com> > On Dec 5, 2016, at 13:50, Dan Carpenter wrote: > > On Fri, Dec 02, 2016 at 02:40:47PM -0500, James Simmons wrote: >> - __u32 local_flags = 0; >> + u32 local_flags = 0; > >> - if (local_flags != 0) { >> + if (local_flags) { > > Please avoid these unrelated white space changes. Some projects (e.g. ext4 that I work with most) allow whitespace changes as part of related changes to the code, since the code is being modified anyway, and frown upon whitespace-only changes because they cause churn in the code and otherwise introduce patch merge conflicts for relatively minor benefits by themselves. My preference is to allow whitespace cleanups in code being modified as part of a patch that is making other fixes, since a few whitespace changes don't typically make it any harder to review the patch. If it gets so far as moving blocks of code between files and this doesn't appear cleanly in the patch then I'd ask for a separate patch. Cheers, Andreas From dan.carpenter at oracle.com Mon Dec 5 22:06:47 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 6 Dec 2016 01:06:47 +0300 Subject: [lustre-devel] [PATCH 3/6] staging: lustre: obdclass: Create a header for obdo related functions In-Reply-To: <2394CAB0-41C1-4F3B-AF94-03D302F6ABF5@intel.com> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> <1480707650-24089-4-git-send-email-jsimmons@infradead.org> <20161205205005.GA31243@mwanda> <2394CAB0-41C1-4F3B-AF94-03D302F6ABF5@intel.com> Message-ID: <20161205220647.GD8244@mwanda> Sorry, I was unclear. I have no problem with white space changes on their own or when they are on the same line as something else you're changing. What I meant is that when you're just moving functions around then don't mix unrelated white space changes into that patch. I have automated scripts for reviewing moving code around but slight changes mean that I have to review it manually line by line to spot the difference. I can review a one liner cleanup in about 10 seconds but it's finding the line which changed that's the problem in this case. And I'm also fine with this patch since I already reviewed it, but in the future, please avoid the temptation to do cleanups until after. regards, dan carpenter From oleg.drokin at intel.com Mon Dec 5 22:44:09 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Mon, 5 Dec 2016 17:44:09 -0500 Subject: [lustre-devel] [PATCH 1/1] staging: lustre: lnet: fix improper return value In-Reply-To: <1480769575-6074-1-git-send-email-bianpan201602@163.com> References: <1480769575-6074-1-git-send-email-bianpan201602@163.com> Message-ID: <2DA842C3-D6EF-472B-9187-A6C681ACD863@intel.com> On Dec 3, 2016, at 7:52 AM, Pan Bian wrote: > From: Pan Bian > > At the end of function lstcon_group_info(), "return 0" seems improper. > It may be better to return the value of rc. > > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188811 > > Signed-off-by: Pan Bian Acked-by: Oleg Drokin > --- > drivers/staging/lustre/lnet/selftest/console.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c > index a0fcbf3..9a7c41a 100644 > --- a/drivers/staging/lustre/lnet/selftest/console.c > +++ b/drivers/staging/lustre/lnet/selftest/console.c > @@ -820,7 +820,7 @@ > > lstcon_group_decref(grp); > > - return 0; > + return rc; > } > > static int > -- > 1.9.1 > From oleg.drokin at intel.com Mon Dec 5 22:48:11 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Mon, 5 Dec 2016 17:48:11 -0500 Subject: [lustre-devel] [PATCH] staging: lustre: mgc: make llog_process_lock static In-Reply-To: <1480904481-20149-1-git-send-email-sandeepjain.linux@gmail.com> References: <1480904481-20149-1-git-send-email-sandeepjain.linux@gmail.com> Message-ID: <57EFF4DF-FEA7-40D5-AD29-4DF3E16D047B@intel.com> On Dec 4, 2016, at 9:21 PM, wrote: > From: Sandeep Jain > > Fix following sparse warning. > mgc_request.c:376:1: > warning: symbol 'llog_process_lock' was not declared. Should it be static? > > Signed-off-by: Sandeep Jain Acked-by: Oleg Drokin > --- > drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c > index 23600fb..e98a2ce 100644 > --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c > +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c > @@ -373,7 +373,7 @@ static int config_log_add(struct obd_device *obd, char *logname, > return rc; > } > > -DEFINE_MUTEX(llog_process_lock); > +static DEFINE_MUTEX(llog_process_lock); > > /** Stop watching for updates on this log. > */ > -- > 2.7.4 From oleg.drokin at intel.com Mon Dec 5 22:50:21 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Mon, 5 Dec 2016 17:50:21 -0500 Subject: [lustre-devel] [PATCH] staging: lustre: Fix function declaration/definition mismatch In-Reply-To: <1480907197-23201-1-git-send-email-sandeepjain.linux@gmail.com> References: <1480907197-23201-1-git-send-email-sandeepjain.linux@gmail.com> Message-ID: On Dec 4, 2016, at 10:06 PM, wrote: > From: Sandeep Jain > > Fixes following Sparse errors. > lprocfs_status.c:1568:5: error: symbol 'lprocfs_wr_root_squash' > redeclared with different type... > lprocfs_status.c:1632:5: error: symbol 'lprocfs_wr_nosquash_nids' > redeclared with different type... > > Signed-off-by: Sandeep Jain Acked-by: Oleg Drokin > --- > drivers/staging/lustre/lustre/include/lprocfs_status.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h > index cc0713e..b5c24ca 100644 > --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h > +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h > @@ -701,9 +701,9 @@ static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store) > extern const struct sysfs_ops lustre_sysfs_ops; > > struct root_squash_info; > -int lprocfs_wr_root_squash(const char *buffer, unsigned long count, > +int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count, > struct root_squash_info *squash, char *name); > -int lprocfs_wr_nosquash_nids(const char *buffer, unsigned long count, > +int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, > struct root_squash_info *squash, char *name); > > /* all quota proc functions */ > -- > 2.7.4 From oleg.drokin at intel.com Mon Dec 5 22:58:06 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Mon, 5 Dec 2016 17:58:06 -0500 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <20161202173332.5100-1-lambert.quentin@gmail.com> References: <20161202173332.5100-1-lambert.quentin@gmail.com> Message-ID: <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> On Dec 2, 2016, at 12:33 PM, Quentin Lambert wrote: > lnet_ipif_enumerate was assigning a pointer from kernel space to user > space. This patch uses copy_to_user to properly do that assignment. I guess it's a false positive? While lnet_sock_ioctl()->kernel_sock_unlocked_ioctl() does call into the f_op->unlocked_ioctl() with a userspace argument, note that we have set_fs(KERNEL_DS); in there, therefore allowig copy_from_user and friends to work on kernel data too as if it was userspace. (I know it's ugly and we need to find a better way of getting this data, but at least it's not incorrect). > > Signed-off-by: Quentin Lambert > --- > shouldn't we be using ifc_req instead of ifc_buf? > > drivers/staging/lustre/lnet/lnet/lib-socket.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c > @@ -181,7 +181,13 @@ lnet_ipif_enumerate(char ***namesp) > goto out0; > } > > - ifc.ifc_buf = (char *)ifr; > + rc = copy_to_user(ifc.ifc_buf, (char *)ifr, > + nalloc * sizeof(*ifr)); > + if (rc) { > + rc = -ENOMEM; > + goto out1; > + } > + > ifc.ifc_len = nalloc * sizeof(*ifr); > > rc = lnet_sock_ioctl(SIOCGIFCONF, (unsigned long)&ifc); > _______________________________________________ > lustre-devel mailing list > lustre-devel at lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org From oleg.drokin at intel.com Mon Dec 5 23:03:58 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Mon, 5 Dec 2016 18:03:58 -0500 Subject: [lustre-devel] [PATCH 04/22] staging: lustre: osc: handle osc eviction correctly In-Reply-To: <20161205205537.GB31465@mwanda> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> <1480726409-20350-5-git-send-email-jsimmons@infradead.org> <20161205205537.GB31465@mwanda> Message-ID: On Dec 5, 2016, at 3:55 PM, Dan Carpenter wrote: > On Fri, Dec 02, 2016 at 07:53:11PM -0500, James Simmons wrote: >> @@ -3183,8 +3182,10 @@ static int discard_cb(const struct lu_env *env, struct cl_io *io, >> /* page is top page. */ >> info->oti_next_index = osc_index(ops) + 1; >> if (cl_page_own(env, io, page) == 0) { >> - KLASSERT(ergo(page->cp_type == CPT_CACHEABLE, >> - !PageDirty(cl_page_vmpage(page)))); >> + if (!ergo(page->cp_type == CPT_CACHEABLE, >> + !PageDirty(cl_page_vmpage(page)))) >> + CL_PAGE_DEBUG(D_ERROR, env, page, >> + "discard dirty page?\n"); > > > I don't understand the point of the ergo macro. There are way too many > double negatives (some of them hidden for my small brain). How is that > simpler than just writing it out: > > if (page->cp_type == CPT_CACHEABLE && > PageDirty(cl_page_vmpage(page)) > CL_PAGE_DEBUG(D_ERROR, env, page, "discard dirty page?\n"); I guess it makes it sound chic or something? I am not a huge fan of it either, esp. in a case like this, though it might be somewhat more convenient in assertions (where this is converted from). From oleg.drokin at intel.com Mon Dec 5 23:43:37 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Mon, 5 Dec 2016 18:43:37 -0500 Subject: [lustre-devel] [bug report] staging: add Lustre file system client support In-Reply-To: <20161123122959.GA17323@mwanda> References: <20161123122959.GA17323@mwanda> Message-ID: On Nov 23, 2016, at 7:29 AM, Dan Carpenter wrote: > Hi Lustre Devs, > > The patch d7e09d0397e8: "staging: add Lustre file system client > support" from May 2, 2013, leads to the following static checker > warning: > > drivers/staging/lustre/lnet/selftest/console.c:1336 lstcon_test_add() > error: 'paramlen' from user is not capped properly > > The story here, is that "paramlen" is capped but only if "param" is > non-NULL. This causes a problem. > > drivers/staging/lustre/lnet/selftest/console.c > 1311 > 1312 LIBCFS_ALLOC(test, offsetof(struct lstcon_test, tes_param[paramlen])); > > We don't know that paramlen is non-NULL here. Because of integer > overflows we could end up allocating less than intended. I think this must be a false positive in this case? Before calling this function we do: LIBCFS_ALLOC(param, args->lstio_tes_param_len); in lst_test_add_ioctl(), so it's not any bigger than 128k (or kmalloc will fail). Even if kmalloc would allow more than 128k allocations, offsetof(struct lstcon_test, tes_param[0]) is bound to be a lot smaller than the baseline allocation address for kmalloc, and therefore integer overflow cannot happen at all. > > 1313 if (!test) { > 1314 CERROR("Can't allocate test descriptor\n"); > 1315 rc = -ENOMEM; > 1316 > 1317 goto out; > 1318 } > 1319 > 1320 test->tes_hdr.tsb_id = batch->bat_hdr.tsb_id; > > Which will lead to memory corruption when we use "test". > > 1321 test->tes_batch = batch; > 1322 test->tes_type = type; > 1323 test->tes_oneside = 0; /* TODO */ > 1324 test->tes_loop = loop; > 1325 test->tes_concur = concur; > 1326 test->tes_stop_onerr = 1; /* TODO */ > 1327 test->tes_span = span; > 1328 test->tes_dist = dist; > 1329 test->tes_cliidx = 0; /* just used for creating RPC */ > 1330 test->tes_src_grp = src_grp; > 1331 test->tes_dst_grp = dst_grp; > 1332 INIT_LIST_HEAD(&test->tes_trans_list); > 1333 > 1334 if (param) { > > Smatch is not smart enough to trace the implication that "'param' is > non-NULL, means that 'paramlen' has been verified" across a function > boundary. Storing that sort of information would really increase the > hardware requirements for running Smatch so it's not something I have > planned currently. > > 1335 test->tes_paramlen = paramlen; > 1336 memcpy(&test->tes_param[0], param, paramlen); > 1337 } > 1338 > > regards, > dan carpenter > _______________________________________________ > lustre-devel mailing list > lustre-devel at lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org From gregkh at linuxfoundation.org Tue Dec 6 09:32:55 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Tue, 6 Dec 2016 10:32:55 +0100 Subject: [lustre-devel] [PATCH 2/6] staging: lustre: headers: sort headers affected by swab move In-Reply-To: <1480707650-24089-3-git-send-email-jsimmons@infradead.org> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> <1480707650-24089-3-git-send-email-jsimmons@infradead.org> Message-ID: <20161206093255.GA28615@kroah.com> On Fri, Dec 02, 2016 at 02:40:46PM -0500, James Simmons wrote: > From: Ben Evans > > It was found if you sort the headers alphabetically > that it reduced patch conflicts. This patch sorts > the headers alphabetically and also place linux > header first, then uapi header and finally the > lustre kernel headers. I really doesn't matter what order you put them in, patch conflicts should still happen at the same frequency :) But I'll take it if it makes people happy... thanks, greg k-h From gregkh at linuxfoundation.org Tue Dec 6 09:36:35 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Tue, 6 Dec 2016 10:36:35 +0100 Subject: [lustre-devel] [PATCH 3/6] staging: lustre: obdclass: Create a header for obdo related functions In-Reply-To: <1480707650-24089-4-git-send-email-jsimmons@infradead.org> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> <1480707650-24089-4-git-send-email-jsimmons@infradead.org> Message-ID: <20161206093635.GA11009@kroah.com> On Fri, Dec 02, 2016 at 02:40:47PM -0500, James Simmons wrote: > From: Ben Evans > > Remove all obdo related functions from lustre_idl.h > Create lustre_odbo.h. Include where appropriate. > Make the functions lustre_get_wire_obdo and > lustre_set_wire_obdo to not be inlined functions. Breaks the build, please test better. I'm dropping this, and the rest of this series from my queue :( greg k-h From gregkh at linuxfoundation.org Tue Dec 6 09:46:20 2016 From: gregkh at linuxfoundation.org (Greg KH) Date: Tue, 6 Dec 2016 10:46:20 +0100 Subject: [lustre-devel] [PATCH TRIVIAL] staging: lustre: lnet: corrected label name. In-Reply-To: <1480754848-10014-1-git-send-email-pandit.parav@gmail.com> References: <1480754848-10014-1-git-send-email-pandit.parav@gmail.com> Message-ID: <20161206094620.GA9880@kroah.com> On Sat, Dec 03, 2016 at 08:47:28AM +0000, Parav Pandit wrote: > Corrected label name from err_destory_routes to err_destroy_routes. > > Signed-off-by: Parav Pandit > --- > drivers/staging/lustre/lnet/lnet/api-ni.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) This is already in the tree :( From gregkh at linuxfoundation.org Tue Dec 6 09:59:58 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Tue, 6 Dec 2016 10:59:58 +0100 Subject: [lustre-devel] [PATCH 14/22] staging: lustre: obd: add callback for llog_cat_process_or_fork In-Reply-To: <1480726409-20350-15-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> <1480726409-20350-15-git-send-email-jsimmons@infradead.org> Message-ID: <20161206095958.GA9387@kroah.com> On Fri, Dec 02, 2016 at 07:53:21PM -0500, James Simmons wrote: > From: Alexander Boyko > > Currently llog_process_or_fork() is hard coded to > always pass the function pointer llog_cat_process_cb(). > Change llog_cat_process_or_fork() to pass in any > function pointer which will allow us more options > for llog_cat callback routines in the future. Don't change this until you have an actual user for this. Adding infrastructure that is not used is not ok for a staging driver, or really any kernel driver at all. sorry, greg k-h From gregkh at linuxfoundation.org Tue Dec 6 10:00:20 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Tue, 6 Dec 2016 11:00:20 +0100 Subject: [lustre-devel] [PATCH 00/22] Next batch of missing work for upstream client In-Reply-To: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> Message-ID: <20161206100020.GB9387@kroah.com> On Fri, Dec 02, 2016 at 07:53:07PM -0500, James Simmons wrote: > Batch of various fixes and clean ups missing in the upstream client. > Only one smaller batch of patches left to sync lustre 2.8.0 version. > These patches are independent of each other so they can be landed > in any order. I've applied most of these now, please fix up the remaining ones and resend. thanks, greg k-h From dan.carpenter at oracle.com Tue Dec 6 11:02:59 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 6 Dec 2016 14:02:59 +0300 Subject: [lustre-devel] [bug report] staging: add Lustre file system client support In-Reply-To: References: <20161123122959.GA17323@mwanda> Message-ID: <20161206110259.GG8244@mwanda> On Mon, Dec 05, 2016 at 06:43:37PM -0500, Oleg Drokin wrote: > > On Nov 23, 2016, at 7:29 AM, Dan Carpenter wrote: > > > Hi Lustre Devs, > > > > The patch d7e09d0397e8: "staging: add Lustre file system client > > support" from May 2, 2013, leads to the following static checker > > warning: > > > > drivers/staging/lustre/lnet/selftest/console.c:1336 lstcon_test_add() > > error: 'paramlen' from user is not capped properly > > > > The story here, is that "paramlen" is capped but only if "param" is > > non-NULL. This causes a problem. > > > > drivers/staging/lustre/lnet/selftest/console.c > > 1311 > > 1312 LIBCFS_ALLOC(test, offsetof(struct lstcon_test, tes_param[paramlen])); > > > > We don't know that paramlen is non-NULL here. Because of integer > > overflows we could end up allocating less than intended. > > I think this must be a false positive in this case? > > Before calling this function we do: > LIBCFS_ALLOC(param, args->lstio_tes_param_len); > > in lst_test_add_ioctl(), so it's not any bigger than 128k (or kmalloc will fail). > Even if kmalloc would allow more than 128k allocations, > offsetof(struct lstcon_test, tes_param[0]) is bound to be a lot smaller than > the baseline allocation address for kmalloc, and therefore integer overflow > cannot happen at all. > I explained badly, and I typed the wrong variable names by mistake... Here is the relevant code from the caller: drivers/staging/lustre/lnet/selftest/conctl.c 710 static int lst_test_add_ioctl(lstio_test_args_t *args) 711 { 712 char *batch_name; 713 char *src_name = NULL; 714 char *dst_name = NULL; 715 void *param = NULL; 716 int ret = 0; 717 int rc = -ENOMEM; 718 719 if (!args->lstio_tes_resultp || 720 !args->lstio_tes_retp || 721 !args->lstio_tes_bat_name || /* no specified batch */ 722 args->lstio_tes_bat_nmlen <= 0 || 723 args->lstio_tes_bat_nmlen > LST_NAME_SIZE || 724 !args->lstio_tes_sgrp_name || /* no source group */ 725 args->lstio_tes_sgrp_nmlen <= 0 || 726 args->lstio_tes_sgrp_nmlen > LST_NAME_SIZE || 727 !args->lstio_tes_dgrp_name || /* no target group */ 728 args->lstio_tes_dgrp_nmlen <= 0 || 729 args->lstio_tes_dgrp_nmlen > LST_NAME_SIZE) 730 return -EINVAL; 731 732 if (!args->lstio_tes_loop || /* negative is infinite */ 733 args->lstio_tes_concur <= 0 || 734 args->lstio_tes_dist <= 0 || 735 args->lstio_tes_span <= 0) 736 return -EINVAL; 737 738 /* have parameter, check if parameter length is valid */ 739 if (args->lstio_tes_param && 740 (args->lstio_tes_param_len <= 0 || 741 args->lstio_tes_param_len > 742 PAGE_SIZE - sizeof(struct lstcon_test))) 743 return -EINVAL; If we don't have a parameter then we don't check ->lstio_tes_param_len. 744 745 LIBCFS_ALLOC(batch_name, args->lstio_tes_bat_nmlen + 1); 746 if (!batch_name) 747 return rc; 748 749 LIBCFS_ALLOC(src_name, args->lstio_tes_sgrp_nmlen + 1); 750 if (!src_name) 751 goto out; 752 753 LIBCFS_ALLOC(dst_name, args->lstio_tes_dgrp_nmlen + 1); 754 if (!dst_name) 755 goto out; 756 757 if (args->lstio_tes_param) { 758 LIBCFS_ALLOC(param, args->lstio_tes_param_len); 759 if (!param) 760 goto out; 761 if (copy_from_user(param, args->lstio_tes_param, 762 args->lstio_tes_param_len)) { 763 rc = -EFAULT; 764 goto out; 765 } 766 } This is the code that you mentioned. But we don't have a parameter so it's not invoked. 767 768 rc = -EFAULT; 769 if (copy_from_user(batch_name, args->lstio_tes_bat_name, 770 args->lstio_tes_bat_nmlen) || 771 copy_from_user(src_name, args->lstio_tes_sgrp_name, 772 args->lstio_tes_sgrp_nmlen) || 773 copy_from_user(dst_name, args->lstio_tes_dgrp_name, 774 args->lstio_tes_dgrp_nmlen)) 775 goto out; 776 777 rc = lstcon_test_add(batch_name, args->lstio_tes_type, 778 args->lstio_tes_loop, args->lstio_tes_concur, 779 args->lstio_tes_dist, args->lstio_tes_span, 780 src_name, dst_name, param, 781 args->lstio_tes_param_len, 782 &ret, args->lstio_tes_resultp); Here we are using "args->lstio_tes_param_len" which could be any integer value. "param" is NULL. 783 784 if (ret) 785 rc = (copy_to_user(args->lstio_tes_retp, &ret, 786 sizeof(ret))) ? -EFAULT : 0; Now here is the code again from lstcon_test_add(): drivers/staging/lustre/lnet/selftest/console.c 1279 int 1280 lstcon_test_add(char *batch_name, int type, int loop, 1281 int concur, int dist, int span, 1282 char *src_name, char *dst_name, 1283 void *param, int paramlen, int *retp, "param" is NULL and "paramlen" is any integer value. 1284 struct list_head __user *result_up) 1285 { 1286 struct lstcon_test *test = NULL; 1287 int rc; 1288 struct lstcon_group *src_grp = NULL; 1289 struct lstcon_group *dst_grp = NULL; 1290 struct lstcon_batch *batch = NULL; 1291 1292 /* 1293 * verify that a batch of the given name exists, and the groups 1294 * that will be part of the batch exist and have at least one 1295 * active node 1296 */ 1297 rc = lstcon_verify_batch(batch_name, &batch); 1298 if (rc) 1299 goto out; 1300 1301 rc = lstcon_verify_group(src_name, &src_grp); 1302 if (rc) 1303 goto out; 1304 1305 rc = lstcon_verify_group(dst_name, &dst_grp); 1306 if (rc) 1307 goto out; 1308 1309 if (dst_grp->grp_userland) 1310 *retp = 1; 1311 1312 LIBCFS_ALLOC(test, offsetof(struct lstcon_test, tes_param[paramlen])); If you pass "paramlen" as -4 then it will corrupt four bytes beyond the end of what we allocated. We could pass paramlen = -108 and it would return ZERO_SIZE_PTR (0x16) and oops. 1313 if (!test) { 1314 CERROR("Can't allocate test descriptor\n"); 1315 rc = -ENOMEM; 1316 1317 goto out; 1318 } 1319 1320 test->tes_hdr.tsb_id = batch->bat_hdr.tsb_id; 1321 test->tes_batch = batch; 1322 test->tes_type = type; 1323 test->tes_oneside = 0; /* TODO */ 1324 test->tes_loop = loop; 1325 test->tes_concur = concur; 1326 test->tes_stop_onerr = 1; /* TODO */ 1327 test->tes_span = span; 1328 test->tes_dist = dist; 1329 test->tes_cliidx = 0; /* just used for creating RPC */ 1330 test->tes_src_grp = src_grp; 1331 test->tes_dst_grp = dst_grp; 1332 INIT_LIST_HEAD(&test->tes_trans_list); 1333 regards, dan carpenter From lambert.quentin at gmail.com Tue Dec 6 13:48:15 2016 From: lambert.quentin at gmail.com (Quentin Lambert) Date: Tue, 6 Dec 2016 14:48:15 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> References: <20161202173332.5100-1-lambert.quentin@gmail.com> <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> Message-ID: <81821426-c32c-c45a-e9a3-82f9818fc986@gmail.com> On 12/05/2016 11:58 PM, Oleg Drokin wrote: > I guess it's a false positive? Yes, probably. Thank you for the explanation though, I don't fully understand all this yet, I am still learning. Sorry for the noise. Quentin From oleg.drokin at intel.com Tue Dec 6 15:34:03 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Tue, 6 Dec 2016 10:34:03 -0500 Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: <20161203085550.GA5375@kroah.com> References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> <20161203085550.GA5375@kroah.com> Message-ID: <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> On Dec 3, 2016, at 3:55 AM, gregkh at linuxfoundation.org wrote: > On Fri, Dec 02, 2016 at 09:53:08PM +0000, Dilger, Andreas wrote: >> Al, >> Greg recently raised the issue of what still needs to be done to >> move the Lustre code out of staging/ and into the fs/ tree. >> >> James has been doing a great job of cleaning up various checkpatch >> issues and keeping the code updated with the latest fixes, but we >> were wondering what you were aware of that needed to be cleaned >> up in Lustre? > > Is the whole "mixing kernel structures in userspace structures" all > resolved now? For some reason I thought that you had kernel locks being > passed to userspace and then back into the kernel, but it's been a long > time since I last looked... While we certainly had our share of mixing user/kernelspace structures, I don't think we ever passed anything with locks around back and forth. I just did a brief check and I don't see anything glaring on this particular front. > If you feel you are ready for a "real" review, I'll be glad to go over > the code before the vfs people look at it, just let me know. No need to > bother them if you still have basic things wrong that I can find… I think this would be beneficial at this stage. Thanks. Bye, Oleg From oleg.drokin at intel.com Tue Dec 6 15:44:54 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Tue, 6 Dec 2016 10:44:54 -0500 Subject: [lustre-devel] [bug report] staging: add Lustre file system client support In-Reply-To: <20161206110259.GG8244@mwanda> References: <20161123122959.GA17323@mwanda> <20161206110259.GG8244@mwanda> Message-ID: <44BA9680-2A0D-49E2-B073-1AA664E8328C@intel.com> On Dec 6, 2016, at 6:02 AM, Dan Carpenter wrote: > On Mon, Dec 05, 2016 at 06:43:37PM -0500, Oleg Drokin wrote: >> >> On Nov 23, 2016, at 7:29 AM, Dan Carpenter wrote: >> >>> Hi Lustre Devs, >>> >>> The patch d7e09d0397e8: "staging: add Lustre file system client >>> support" from May 2, 2013, leads to the following static checker >>> warning: >>> >>> drivers/staging/lustre/lnet/selftest/console.c:1336 lstcon_test_add() >>> error: 'paramlen' from user is not capped properly >>> >>> The story here, is that "paramlen" is capped but only if "param" is >>> non-NULL. This causes a problem. >>> >>> drivers/staging/lustre/lnet/selftest/console.c >>> 1311 >>> 1312 LIBCFS_ALLOC(test, offsetof(struct lstcon_test, tes_param[paramlen])); >>> >>> We don't know that paramlen is non-NULL here. Because of integer >>> overflows we could end up allocating less than intended. >> >> I think this must be a false positive in this case? >> >> Before calling this function we do: >> LIBCFS_ALLOC(param, args->lstio_tes_param_len); >> >> in lst_test_add_ioctl(), so it's not any bigger than 128k (or kmalloc will fail). >> Even if kmalloc would allow more than 128k allocations, >> offsetof(struct lstcon_test, tes_param[0]) is bound to be a lot smaller than >> the baseline allocation address for kmalloc, and therefore integer overflow >> cannot happen at all. >> > > I explained badly, and I typed the wrong variable names by mistake... > Here is the relevant code from the caller: > > drivers/staging/lustre/lnet/selftest/conctl.c > 710 static int lst_test_add_ioctl(lstio_test_args_t *args) > 711 { > 712 char *batch_name; > 713 char *src_name = NULL; > 714 char *dst_name = NULL; > 715 void *param = NULL; > 716 int ret = 0; > 717 int rc = -ENOMEM; > 718 > 719 if (!args->lstio_tes_resultp || > 720 !args->lstio_tes_retp || > 721 !args->lstio_tes_bat_name || /* no specified batch */ > 722 args->lstio_tes_bat_nmlen <= 0 || > 723 args->lstio_tes_bat_nmlen > LST_NAME_SIZE || > 724 !args->lstio_tes_sgrp_name || /* no source group */ > 725 args->lstio_tes_sgrp_nmlen <= 0 || > 726 args->lstio_tes_sgrp_nmlen > LST_NAME_SIZE || > 727 !args->lstio_tes_dgrp_name || /* no target group */ > 728 args->lstio_tes_dgrp_nmlen <= 0 || > 729 args->lstio_tes_dgrp_nmlen > LST_NAME_SIZE) > 730 return -EINVAL; > 731 > 732 if (!args->lstio_tes_loop || /* negative is infinite */ > 733 args->lstio_tes_concur <= 0 || > 734 args->lstio_tes_dist <= 0 || > 735 args->lstio_tes_span <= 0) > 736 return -EINVAL; > 737 > 738 /* have parameter, check if parameter length is valid */ > 739 if (args->lstio_tes_param && > 740 (args->lstio_tes_param_len <= 0 || > 741 args->lstio_tes_param_len > > 742 PAGE_SIZE - sizeof(struct lstcon_test))) > 743 return -EINVAL; > > If we don't have a parameter then we don't check ->lstio_tes_param_len. I see, indeed, it all makes sense now. So basically if we unconditionally check for the size to be > 0, we should be fine then, I imagine. On the other hand there's probably no se for no param and nonzero param len, so it's probably even better to enforce size as zero when no param. Thank you. From gregkh at linuxfoundation.org Tue Dec 6 16:15:24 2016 From: gregkh at linuxfoundation.org (Greg KH) Date: Tue, 6 Dec 2016 17:15:24 +0100 Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> <20161203085550.GA5375@kroah.com> <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> Message-ID: <20161206161524.GA5535@kroah.com> On Tue, Dec 06, 2016 at 10:34:03AM -0500, Oleg Drokin wrote: > > On Dec 3, 2016, at 3:55 AM, gregkh at linuxfoundation.org wrote: > > > On Fri, Dec 02, 2016 at 09:53:08PM +0000, Dilger, Andreas wrote: > >> Al, > >> Greg recently raised the issue of what still needs to be done to > >> move the Lustre code out of staging/ and into the fs/ tree. > >> > >> James has been doing a great job of cleaning up various checkpatch > >> issues and keeping the code updated with the latest fixes, but we > >> were wondering what you were aware of that needed to be cleaned > >> up in Lustre? > > > > Is the whole "mixing kernel structures in userspace structures" all > > resolved now? For some reason I thought that you had kernel locks being > > passed to userspace and then back into the kernel, but it's been a long > > time since I last looked... > > While we certainly had our share of mixing user/kernelspace structures, > I don't think we ever passed anything with locks around back and forth. > > I just did a brief check and I don't see anything glaring on this particular front. > > > If you feel you are ready for a "real" review, I'll be glad to go over > > the code before the vfs people look at it, just let me know. No need to > > bother them if you still have basic things wrong that I can find… > > I think this would be beneficial at this stage. I see loads of checkpatch.pl warnings and a few errors, how about fixing all of them up first? thanks, greg k-h From oleg.drokin at intel.com Tue Dec 6 17:50:08 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Tue, 6 Dec 2016 12:50:08 -0500 Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: <20161206161524.GA5535@kroah.com> References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> <20161203085550.GA5375@kroah.com> <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> <20161206161524.GA5535@kroah.com> Message-ID: <7AF464A9-1D0F-48E9-B83C-66F983268473@intel.com> On Dec 6, 2016, at 11:15 AM, Greg KH wrote: > On Tue, Dec 06, 2016 at 10:34:03AM -0500, Oleg Drokin wrote: >> >> On Dec 3, 2016, at 3:55 AM, gregkh at linuxfoundation.org wrote: >> >>> On Fri, Dec 02, 2016 at 09:53:08PM +0000, Dilger, Andreas wrote: >>>> Al, >>>> Greg recently raised the issue of what still needs to be done to >>>> move the Lustre code out of staging/ and into the fs/ tree. >>>> >>>> James has been doing a great job of cleaning up various checkpatch >>>> issues and keeping the code updated with the latest fixes, but we >>>> were wondering what you were aware of that needed to be cleaned >>>> up in Lustre? >>> >>> Is the whole "mixing kernel structures in userspace structures" all >>> resolved now? For some reason I thought that you had kernel locks being >>> passed to userspace and then back into the kernel, but it's been a long >>> time since I last looked... >> >> While we certainly had our share of mixing user/kernelspace structures, >> I don't think we ever passed anything with locks around back and forth. >> >> I just did a brief check and I don't see anything glaring on this particular front. >> >>> If you feel you are ready for a "real" review, I'll be glad to go over >>> the code before the vfs people look at it, just let me know. No need to >>> bother them if you still have basic things wrong that I can find… >> >> I think this would be beneficial at this stage. > > I see loads of checkpatch.pl warnings and a few errors, how about fixing > all of them up first? > There are 16 errors, of them: 8 are false positives in drivers/staging/lustre/lnet/libcfs/hash.c 1 false positive in drivers/staging/lustre/lnet/libcfs/tracefile.h 1 false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h 1 I think false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h (PLDLMRES) 2 false positives in drivers/staging/lustre/lustre/include/lustre/lustre_user.h an error I don't really understand, what does it want us to do here? ERROR: trailing statements should be on next line #196951: FILE: drivers/staging/lustre/lustre/mdc/mdc_request.c:1063: + for (end_dirent = ent; ent; + end_dirent = ent, ent = lu_dirent_next(ent)); leaving 2 real ones, one missing space in drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c and 1 spaces instead of tabs in drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h I'll have patches shortly for these. On the warning front, we have 879 line over 80 characters, but a bunch of those are due to long error messages that we cannot split into a multiline thing anyway. 71 Prefer 'unsigned int' to bare use of 'unsigned' that is a relatively new one 22 new typedefs (all in lnet, I drove out all the lustre ones, so I guess I can tackle these too). a bunch of comment style problems a few "function definition argument … should also have an identifier name" that seems to be a new one too, I don't remember seeing this before. And a bunch of rarer ones for the total of 1243 (823 in just Lustre). Multiple classes of them are actually not easily fixable or false positives too. Do you really want all of these fixed too somehow? From gregkh at linuxfoundation.org Tue Dec 6 18:05:22 2016 From: gregkh at linuxfoundation.org (Greg KH) Date: Tue, 6 Dec 2016 19:05:22 +0100 Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: <7AF464A9-1D0F-48E9-B83C-66F983268473@intel.com> References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> <20161203085550.GA5375@kroah.com> <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> <20161206161524.GA5535@kroah.com> <7AF464A9-1D0F-48E9-B83C-66F983268473@intel.com> Message-ID: <20161206180522.GB16256@kroah.com> On Tue, Dec 06, 2016 at 12:50:08PM -0500, Oleg Drokin wrote: > > On Dec 6, 2016, at 11:15 AM, Greg KH wrote: > > > On Tue, Dec 06, 2016 at 10:34:03AM -0500, Oleg Drokin wrote: > >> > >> On Dec 3, 2016, at 3:55 AM, gregkh at linuxfoundation.org wrote: > >> > >>> On Fri, Dec 02, 2016 at 09:53:08PM +0000, Dilger, Andreas wrote: > >>>> Al, > >>>> Greg recently raised the issue of what still needs to be done to > >>>> move the Lustre code out of staging/ and into the fs/ tree. > >>>> > >>>> James has been doing a great job of cleaning up various checkpatch > >>>> issues and keeping the code updated with the latest fixes, but we > >>>> were wondering what you were aware of that needed to be cleaned > >>>> up in Lustre? > >>> > >>> Is the whole "mixing kernel structures in userspace structures" all > >>> resolved now? For some reason I thought that you had kernel locks being > >>> passed to userspace and then back into the kernel, but it's been a long > >>> time since I last looked... > >> > >> While we certainly had our share of mixing user/kernelspace structures, > >> I don't think we ever passed anything with locks around back and forth. > >> > >> I just did a brief check and I don't see anything glaring on this particular front. > >> > >>> If you feel you are ready for a "real" review, I'll be glad to go over > >>> the code before the vfs people look at it, just let me know. No need to > >>> bother them if you still have basic things wrong that I can find… > >> > >> I think this would be beneficial at this stage. > > > > I see loads of checkpatch.pl warnings and a few errors, how about fixing > > all of them up first? > > > > There are 16 errors, > of them: > 8 are false positives in drivers/staging/lustre/lnet/libcfs/hash.c > 1 false positive in drivers/staging/lustre/lnet/libcfs/tracefile.h > 1 false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h > 1 I think false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h (PLDLMRES) > 2 false positives in drivers/staging/lustre/lustre/include/lustre/lustre_user.h > > an error I don't really understand, what does it want us to do here? > ERROR: trailing statements should be on next line > #196951: FILE: drivers/staging/lustre/lustre/mdc/mdc_request.c:1063: > + for (end_dirent = ent; ent; > + end_dirent = ent, ent = lu_dirent_next(ent)); That's odd, I think the perl script just got confused. > leaving 2 real ones, one missing space in drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > and 1 spaces instead of tabs in drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h > > I'll have patches shortly for these. > > On the warning front, we have 879 line over 80 characters, but a bunch > of those are due to long error messages that we cannot split into a multiline thing anyway. Change to use a "sane" logging function and then all of those will go away. You all should do that anyway, the macro mess you have now is looney. > 71 Prefer 'unsigned int' to bare use of 'unsigned' that is a relatively new one > 22 new typedefs (all in lnet, I drove out all the lustre ones, so I guess I can tackle these too). > a bunch of comment style problems > a few "function definition argument … should also have an identifier name" that > seems to be a new one too, I don't remember seeing this before. > > And a bunch of rarer ones for the total of 1243 (823 in just Lustre). > Multiple classes of them are actually not easily fixable or false positives too. > Do you really want all of these fixed too somehow? The real ones, yes. Why wouldn't you? And work on that logging mess if at all possible as well :) thanks, greg k-h From adilger at dilger.ca Tue Dec 6 18:05:48 2016 From: adilger at dilger.ca (Andreas Dilger) Date: Tue, 6 Dec 2016 11:05:48 -0700 Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: <7AF464A9-1D0F-48E9-B83C-66F983268473@intel.com> References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> <20161203085550.GA5375@kroah.com> <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> <20161206161524.GA5535@kroah.com> <7AF464A9-1D0F-48E9-B83C-66F983268473@intel.com> Message-ID: On Dec 6, 2016, at 10:50 AM, Oleg Drokin wrote: > > On Dec 6, 2016, at 11:15 AM, Greg KH wrote: >> I see loads of checkpatch.pl warnings and a few errors, how about fixing >> all of them up first? > > There are 16 errors, > of them: > 8 are false positives in drivers/staging/lustre/lnet/libcfs/hash.c > 1 false positive in drivers/staging/lustre/lnet/libcfs/tracefile.h > 1 false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h > 1 I think false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h (PLDLMRES) > 2 false positives in drivers/staging/lustre/lustre/include/lustre/lustre_user.h > > an error I don't really understand, what does it want us to do here? > ERROR: trailing statements should be on next line > #196951: FILE: drivers/staging/lustre/lustre/mdc/mdc_request.c:1063: > + for (end_dirent = ent; ent; > + end_dirent = ent, ent = lu_dirent_next(ent)); > > leaving 2 real ones, one missing space in drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > and 1 spaces instead of tabs in drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h > > I'll have patches shortly for these. > > On the warning front, we have 879 line over 80 characters, but a bunch > of those are due to long error messages that we cannot split into a multiline thing anyway. > 71 Prefer 'unsigned int' to bare use of 'unsigned' that is a relatively new one > 22 new typedefs (all in lnet, I drove out all the lustre ones, so I guess I can tackle these too). I think James already has a patch series getting rid of typedefs from LNet? > a bunch of comment style problems > a few "function definition argument … should also have an identifier name" that > seems to be a new one too, I don't remember seeing this before. > > And a bunch of rarer ones for the total of 1243 (823 in just Lustre). > Multiple classes of them are actually not easily fixable or false positives too. > Do you really want all of these fixed too somehow? Cheers, Andreas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: Message signed with OpenPGP using GPGMail URL: From oleg.drokin at intel.com Tue Dec 6 18:14:28 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Tue, 6 Dec 2016 13:14:28 -0500 Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> <20161203085550.GA5375@kroah.com> <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> <20161206161524.GA5535@kroah.com> <7AF464A9-1D0F-48E9-B83C-66F983268473@intel.com> Message-ID: <606EDBC7-4555-42DD-85E7-66620E601C85@intel.com> On Dec 6, 2016, at 1:07 PM, Mike Marshall wrote: > > long error messages that we cannot split into a multiline thing anyway. > > I split numerous Orangefs ones at substitution characters, which > didn't break grepability. No one complained, and sure made > stuff look nicer to me. You might be able to do that some places? Checkpatch still complains about this I believe. > > -Mike > > On Tue, Dec 6, 2016 at 12:50 PM, Oleg Drokin wrote: > > On Dec 6, 2016, at 11:15 AM, Greg KH wrote: > > > On Tue, Dec 06, 2016 at 10:34:03AM -0500, Oleg Drokin wrote: > >> > >> On Dec 3, 2016, at 3:55 AM, gregkh at linuxfoundation.org wrote: > >> > >>> On Fri, Dec 02, 2016 at 09:53:08PM +0000, Dilger, Andreas wrote: > >>>> Al, > >>>> Greg recently raised the issue of what still needs to be done to > >>>> move the Lustre code out of staging/ and into the fs/ tree. > >>>> > >>>> James has been doing a great job of cleaning up various checkpatch > >>>> issues and keeping the code updated with the latest fixes, but we > >>>> were wondering what you were aware of that needed to be cleaned > >>>> up in Lustre? > >>> > >>> Is the whole "mixing kernel structures in userspace structures" all > >>> resolved now? For some reason I thought that you had kernel locks being > >>> passed to userspace and then back into the kernel, but it's been a long > >>> time since I last looked... > >> > >> While we certainly had our share of mixing user/kernelspace structures, > >> I don't think we ever passed anything with locks around back and forth. > >> > >> I just did a brief check and I don't see anything glaring on this particular front. > >> > >>> If you feel you are ready for a "real" review, I'll be glad to go over > >>> the code before the vfs people look at it, just let me know. No need to > >>> bother them if you still have basic things wrong that I can find… > >> > >> I think this would be beneficial at this stage. > > > > I see loads of checkpatch.pl warnings and a few errors, how about fixing > > all of them up first? > > > > There are 16 errors, > of them: > 8 are false positives in drivers/staging/lustre/lnet/libcfs/hash.c > 1 false positive in drivers/staging/lustre/lnet/libcfs/tracefile.h > 1 false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h > 1 I think false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h (PLDLMRES) > 2 false positives in drivers/staging/lustre/lustre/include/lustre/lustre_user.h > > an error I don't really understand, what does it want us to do here? > ERROR: trailing statements should be on next line > #196951: FILE: drivers/staging/lustre/lustre/mdc/mdc_request.c:1063: > + for (end_dirent = ent; ent; > + end_dirent = ent, ent = lu_dirent_next(ent)); > > leaving 2 real ones, one missing space in drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > and 1 spaces instead of tabs in drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h > > I'll have patches shortly for these. > > On the warning front, we have 879 line over 80 characters, but a bunch > of those are due to long error messages that we cannot split into a multiline thing anyway. > 71 Prefer 'unsigned int' to bare use of 'unsigned' that is a relatively new one > 22 new typedefs (all in lnet, I drove out all the lustre ones, so I guess I can tackle these too). > a bunch of comment style problems > a few "function definition argument … should also have an identifier name" that > seems to be a new one too, I don't remember seeing this before. > > And a bunch of rarer ones for the total of 1243 (823 in just Lustre). > Multiple classes of them are actually not easily fixable or false positives too. > Do you really want all of these fixed too somehow? > > -- > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo at vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > From dan.carpenter at oracle.com Tue Dec 6 18:37:39 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 6 Dec 2016 21:37:39 +0300 Subject: [lustre-devel] [bug report] staging: add Lustre file system client support In-Reply-To: <44BA9680-2A0D-49E2-B073-1AA664E8328C@intel.com> References: <20161123122959.GA17323@mwanda> <20161206110259.GG8244@mwanda> <44BA9680-2A0D-49E2-B073-1AA664E8328C@intel.com> Message-ID: <20161206183739.GI8244@mwanda> On Tue, Dec 06, 2016 at 10:44:54AM -0500, Oleg Drokin wrote: > I see, indeed, it all makes sense now. > So basically if we unconditionally check for the size to be > 0, we should be > fine then, I imagine. > On the other hand there's probably no se for no param and nonzero param len, > so it's probably even better to enforce size as zero when no param. Checking for > 0 is not enough, because it could also have an integer overflow on 32 bit systems. We need to cap the upper bound as well. regards, dan carpenter From oleg.drokin at intel.com Tue Dec 6 19:10:13 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Tue, 6 Dec 2016 14:10:13 -0500 Subject: [lustre-devel] [bug report] staging: add Lustre file system client support In-Reply-To: <20161206183739.GI8244@mwanda> References: <20161123122959.GA17323@mwanda> <20161206110259.GG8244@mwanda> <44BA9680-2A0D-49E2-B073-1AA664E8328C@intel.com> <20161206183739.GI8244@mwanda> Message-ID: On Dec 6, 2016, at 1:37 PM, Dan Carpenter wrote: > On Tue, Dec 06, 2016 at 10:44:54AM -0500, Oleg Drokin wrote: >> I see, indeed, it all makes sense now. >> So basically if we unconditionally check for the size to be > 0, we should be >> fine then, I imagine. >> On the other hand there's probably no se for no param and nonzero param len, >> so it's probably even better to enforce size as zero when no param. > > Checking for > 0 is not enough, because it could also have an integer > overflow on 32 bit systems. We need to cap the upper bound as well. How would it play out, though? offsetof(struct lstcon_test, tes_param[large_positive_int]) would result in some real "large" negative number. So trying to allocate this many negative bytes would fail, right? From dan.carpenter at oracle.com Tue Dec 6 19:19:38 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 6 Dec 2016 22:19:38 +0300 Subject: [lustre-devel] [bug report] staging: add Lustre file system client support In-Reply-To: References: <20161123122959.GA17323@mwanda> <20161206110259.GG8244@mwanda> <44BA9680-2A0D-49E2-B073-1AA664E8328C@intel.com> <20161206183739.GI8244@mwanda> Message-ID: <20161206191938.GL8176@mwanda> On Tue, Dec 06, 2016 at 02:10:13PM -0500, Oleg Drokin wrote: > > On Dec 6, 2016, at 1:37 PM, Dan Carpenter wrote: > > > On Tue, Dec 06, 2016 at 10:44:54AM -0500, Oleg Drokin wrote: > >> I see, indeed, it all makes sense now. > >> So basically if we unconditionally check for the size to be > 0, we should be > >> fine then, I imagine. > >> On the other hand there's probably no se for no param and nonzero param len, > >> so it's probably even better to enforce size as zero when no param. > > > > Checking for > 0 is not enough, because it could also have an integer > > overflow on 32 bit systems. We need to cap the upper bound as well. > > How would it play out, though? > offsetof(struct lstcon_test, tes_param[large_positive_int]) would result in > some real "large" negative number. > So trying to allocate this many negative bytes would fail, right? Oh, yeah. You're right. Good point... regards, dan carpenter From gregkh at linuxfoundation.org Tue Dec 6 20:14:07 2016 From: gregkh at linuxfoundation.org (Greg KH) Date: Tue, 6 Dec 2016 21:14:07 +0100 Subject: [lustre-devel] [bug report] staging: add Lustre file system client support In-Reply-To: References: <20161123122959.GA17323@mwanda> <20161206110259.GG8244@mwanda> <44BA9680-2A0D-49E2-B073-1AA664E8328C@intel.com> <20161206183739.GI8244@mwanda> Message-ID: <20161206201407.GA22765@kroah.com> On Tue, Dec 06, 2016 at 02:10:13PM -0500, Oleg Drokin wrote: > > On Dec 6, 2016, at 1:37 PM, Dan Carpenter wrote: > > > On Tue, Dec 06, 2016 at 10:44:54AM -0500, Oleg Drokin wrote: > >> I see, indeed, it all makes sense now. > >> So basically if we unconditionally check for the size to be > 0, we should be > >> fine then, I imagine. > >> On the other hand there's probably no se for no param and nonzero param len, > >> so it's probably even better to enforce size as zero when no param. > > > > Checking for > 0 is not enough, because it could also have an integer > > overflow on 32 bit systems. We need to cap the upper bound as well. > > How would it play out, though? > offsetof(struct lstcon_test, tes_param[large_positive_int]) would result in > some real "large" negative number. > So trying to allocate this many negative bytes would fail, right? Not always. Please properly bound your allocations. thanks, greg k-h From green at linuxhacker.ru Wed Dec 7 03:53:48 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Tue, 6 Dec 2016 22:53:48 -0500 Subject: [lustre-devel] [PATCH] staging/lustre/osc: Revert erroneous list_for_each_entry_safe use Message-ID: <1481082828-1590398-1-git-send-email-green@linuxhacker.ru> I have been having a lot of unexplainable crashes in osc_lru_shrink lately that I could not see a good explanation for and then I found this patch that slip under the radar somehow that incorrectly converted while loop for lru list iteration into list_for_each_entry_safe totally ignoring that in the body of the loop we drop spinlocks guarding this list and move list entries around. Not sure why it was not showing up right away, perhaps some of the more recent LRU changes committed caused some extra pressure on this code that finally highlighted the breakage. Reverts: 8adddc36b1fc ("staging: lustre: osc: Use list_for_each_entry_safe") CC: Bhaktipriya Shridhar Signed-off-by: Oleg Drokin --- I also do not see this patch in any of the mailing lists I am subscribed to. I wonder if there's a way to subscribe to those Greg's "This is a note to let you know that I've just added the patch ...." emails that concern Lustre to get them even if I am not on the CC list in the patch itself? drivers/staging/lustre/lustre/osc/osc_page.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index c5129d1..e356e4a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -537,7 +537,6 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, struct cl_object *clobj = NULL; struct cl_page **pvec; struct osc_page *opg; - struct osc_page *temp; int maxscan = 0; long count = 0; int index = 0; @@ -568,7 +567,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, if (force) cli->cl_lru_reclaim++; maxscan = min(target << 1, atomic_long_read(&cli->cl_lru_in_list)); - list_for_each_entry_safe(opg, temp, &cli->cl_lru_list, ops_lru) { + while (!list_empty(&cli->cl_lru_list)) { struct cl_page *page; bool will_free = false; @@ -578,6 +577,8 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, if (--maxscan < 0) break; + opg = list_entry(cli->cl_lru_list.next, struct osc_page, + ops_lru); page = opg->ops_cl.cpl_page; if (lru_page_busy(cli, page)) { list_move_tail(&opg->ops_lru, &cli->cl_lru_list); -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 04:57:40 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Tue, 6 Dec 2016 23:57:40 -0500 Subject: [lustre-devel] [PATCH 5/5] staging/lustre/o2iblnd: Fix misspelled attemps->attempts In-Reply-To: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> References: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481086660-1610943-6-git-send-email-green@linuxhacker.ru> Highlighted by checkpatch: WARNING: 'attemps' may be misspelled - perhaps 'attempts'? #20278: FILE: drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:3272: + * reconnection attemps. Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index bea408d..c7917ab 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -3269,7 +3269,7 @@ kiblnd_disconnect_conn(struct kib_conn *conn) #define KIB_RECONN_HIGH_RACE 10 /** * Allow connd to take a break and handle other things after consecutive - * reconnection attemps. + * reconnection attempts. */ #define KIB_RECONN_BREAK 100 -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 04:57:36 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Tue, 6 Dec 2016 23:57:36 -0500 Subject: [lustre-devel] [PATCH 1/5] staging/lustre/o2iblnd: Add missing space In-Reply-To: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> References: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481086660-1610943-2-git-send-email-green@linuxhacker.ru> checkpatch highlighted missing space before assignment for lock variable. + spinlock_t *lock= &kiblnd_data.kib_connd_lock; Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 92692a2..bea408d 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -3276,7 +3276,7 @@ kiblnd_disconnect_conn(struct kib_conn *conn) int kiblnd_connd(void *arg) { - spinlock_t *lock= &kiblnd_data.kib_connd_lock; + spinlock_t *lock = &kiblnd_data.kib_connd_lock; wait_queue_t wait; unsigned long flags; struct kib_conn *conn; -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 04:57:37 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Tue, 6 Dec 2016 23:57:37 -0500 Subject: [lustre-devel] [PATCH 2/5] staging/lustre/socklnd: Fix whitespace problem In-Reply-To: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> References: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481086660-1610943-3-git-send-email-green@linuxhacker.ru> checkpatch highlighted there are 8 spaces that could be converted to a tab: ERROR: code indent should use tabs where possible +^I^I^I^I^I */$ Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index 2978014..842c453 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -334,7 +334,7 @@ struct ksock_conn { atomic_t ksnc_conn_refcount;/* conn refcount */ atomic_t ksnc_sock_refcount;/* sock refcount */ struct ksock_sched *ksnc_scheduler; /* who schedules this connection - */ + */ __u32 ksnc_myipaddr; /* my IP */ __u32 ksnc_ipaddr; /* peer's IP */ int ksnc_port; /* peer's port */ -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 04:57:38 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Tue, 6 Dec 2016 23:57:38 -0500 Subject: [lustre-devel] [PATCH 3/5] staging/lustre: Convert all bare unsigned to unsigned int In-Reply-To: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> References: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481086660-1610943-4-git-send-email-green@linuxhacker.ru> Highlighted by relatively new checkpatch test, warnings like: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Signed-off-by: Oleg Drokin --- drivers/staging/lustre/include/linux/lnet/lnetst.h | 6 +- .../staging/lustre/lustre/include/lprocfs_status.h | 3 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 8 +- drivers/staging/lustre/lustre/llite/llite_nfs.c | 2 +- drivers/staging/lustre/lustre/llite/rw26.c | 4 +- drivers/staging/lustre/lustre/llite/xattr_cache.c | 6 +- drivers/staging/lustre/lustre/lov/lov_pool.c | 3 +- .../lustre/lustre/obdclass/lprocfs_status.c | 3 +- drivers/staging/lustre/lustre/obdclass/lu_object.c | 6 +- .../staging/lustre/lustre/obdclass/obd_config.c | 4 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 2 +- drivers/staging/lustre/lustre/osc/osc_quota.c | 4 +- drivers/staging/lustre/lustre/osc/osc_request.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/connection.c | 4 +- .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 92 +++++++++++----------- 17 files changed, 83 insertions(+), 80 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index 78f825d..8a84888 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -244,7 +244,7 @@ typedef struct { int lstio_ses_timeout; /* IN: session timeout */ int lstio_ses_force; /* IN: force create ? */ /** IN: session features */ - unsigned lstio_ses_feats; + unsigned int lstio_ses_feats; lst_sid_t __user *lstio_ses_idp; /* OUT: session id */ int lstio_ses_nmlen; /* IN: name length */ char __user *lstio_ses_namep; /* IN: session name */ @@ -255,7 +255,7 @@ typedef struct { lst_sid_t __user *lstio_ses_idp; /* OUT: session id */ int __user *lstio_ses_keyp; /* OUT: local key */ /** OUT: session features */ - unsigned __user *lstio_ses_featp; + unsigned int __user *lstio_ses_featp; lstcon_ndlist_ent_t __user *lstio_ses_ndinfo; /* OUT: */ int lstio_ses_nmlen; /* IN: name length */ char __user *lstio_ses_namep; /* OUT: session name */ @@ -328,7 +328,7 @@ typedef struct { char __user *lstio_grp_namep; /* IN: group name */ int lstio_grp_count; /* IN: # of nodes */ /** OUT: session features */ - unsigned __user *lstio_grp_featp; + unsigned int __user *lstio_grp_featp; lnet_process_id_t __user *lstio_grp_idsp; /* IN: nodes */ struct list_head __user *lstio_grp_resultp; /* OUT: list head of result buffer */ diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index adef2d2..62753da 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -542,7 +542,8 @@ lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags); void lprocfs_clear_stats(struct lprocfs_stats *stats); void lprocfs_free_stats(struct lprocfs_stats **stats); void lprocfs_counter_init(struct lprocfs_stats *stats, int index, - unsigned conf, const char *name, const char *units); + unsigned int conf, const char *name, + const char *units); struct obd_export; int lprocfs_exp_cleanup(struct obd_export *exp); struct dentry *ldebugfs_add_simple(struct dentry *root, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 1095331..b22f5ba 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -445,8 +445,8 @@ static struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res) return res; } -static unsigned ldlm_res_hop_hash(struct cfs_hash *hs, - const void *key, unsigned mask) +static unsigned int ldlm_res_hop_hash(struct cfs_hash *hs, + const void *key, unsigned int mask) { const struct ldlm_res_id *id = key; unsigned int val = 0; @@ -457,8 +457,8 @@ static unsigned ldlm_res_hop_hash(struct cfs_hash *hs, return val & mask; } -static unsigned ldlm_res_hop_fid_hash(struct cfs_hash *hs, - const void *key, unsigned mask) +static unsigned int ldlm_res_hop_fid_hash(struct cfs_hash *hs, + const void *key, unsigned int mask) { const struct ldlm_res_id *id = key; struct lu_fid fid; diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 7092305..c632365 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -226,7 +226,7 @@ static int ll_encode_fh(struct inode *inode, __u32 *fh, int *plen, static int ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name, int namelen, loff_t hash, u64 ino, - unsigned type) + unsigned int type) { /* It is hack to access lde_fid for comparison with lgd_fid. * So the input 'name' must be part of the 'lu_dirent'. diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index c1b7409..21e06e5 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -460,7 +460,7 @@ static int ll_prepare_partial_page(const struct lu_env *env, struct cl_io *io, } static int ll_write_begin(struct file *file, struct address_space *mapping, - loff_t pos, unsigned len, unsigned flags, + loff_t pos, unsigned int len, unsigned int flags, struct page **pagep, void **fsdata) { struct ll_cl_context *lcc; @@ -577,7 +577,7 @@ static int ll_write_end(struct file *file, struct address_space *mapping, struct cl_io *io; struct vvp_io *vio; struct cl_page *page; - unsigned from = pos & (PAGE_SIZE - 1); + unsigned int from = pos & (PAGE_SIZE - 1); bool unplug = false; int result = 0; diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index 198b051..38f75f6 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -26,8 +26,8 @@ struct ll_xattr_entry { */ char *xe_name; /* xattr name, \0-terminated */ char *xe_value; /* xattr value */ - unsigned xe_namelen; /* strlen(xe_name) + 1 */ - unsigned xe_vallen; /* xattr value length */ + unsigned int xe_namelen; /* strlen(xe_name) + 1 */ + unsigned int xe_vallen; /* xattr value length */ }; static struct kmem_cache *xattr_kmem; @@ -104,7 +104,7 @@ static int ll_xattr_cache_find(struct list_head *cache, static int ll_xattr_cache_add(struct list_head *cache, const char *xattr_name, const char *xattr_val, - unsigned xattr_val_len) + unsigned int xattr_val_len) { struct ll_xattr_entry *xattr; diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index f8c8a36..7daa867 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -81,7 +81,8 @@ static void lov_pool_putref_locked(struct pool_desc *pool) * Chapter 6.4. * Addison Wesley, 1973 */ -static __u32 pool_hashfn(struct cfs_hash *hash_body, const void *key, unsigned mask) +static __u32 pool_hashfn(struct cfs_hash *hash_body, const void *key, + unsigned int mask) { int i; __u32 result; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 2f2e8fcb..2c99717 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1289,7 +1289,8 @@ int ldebugfs_register_stats(struct dentry *parent, const char *name, EXPORT_SYMBOL_GPL(ldebugfs_register_stats); void lprocfs_counter_init(struct lprocfs_stats *stats, int index, - unsigned conf, const char *name, const char *units) + unsigned int conf, const char *name, + const char *units) { struct lprocfs_counter_header *header; struct lprocfs_counter *percpu_cntr; diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 80e0984..7971562 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -914,8 +914,8 @@ static unsigned long lu_htable_order(struct lu_device *top) return clamp_t(typeof(bits), bits, LU_SITE_BITS_MIN, bits_max); } -static unsigned lu_obj_hop_hash(struct cfs_hash *hs, - const void *key, unsigned mask) +static unsigned int lu_obj_hop_hash(struct cfs_hash *hs, + const void *key, unsigned int mask) { struct lu_fid *fid = (struct lu_fid *)key; __u32 hash; @@ -1324,7 +1324,7 @@ static atomic_t lu_key_initing_cnt = ATOMIC_INIT(0); * lu_context_refill(). No locking is provided, as initialization and shutdown * are supposed to be externally serialized. */ -static unsigned key_set_version; +static unsigned int key_set_version; /** * Register new key. diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 0a55d79..9ca84c7 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -1450,8 +1450,8 @@ EXPORT_SYMBOL(class_manual_cleanup); * uuid<->export lustre hash operations */ -static unsigned -uuid_hash(struct cfs_hash *hs, const void *key, unsigned mask) +static unsigned int +uuid_hash(struct cfs_hash *hs, const void *key, unsigned int mask) { return cfs_hash_djb2_hash(((struct obd_uuid *)key)->uuid, sizeof(((struct obd_uuid *)key)->uuid), mask); diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 001fe75..5f799a4 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -188,7 +188,7 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct cl_object *obj = osc2cl(osc); struct lov_oinfo *oinfo = osc->oo_oinfo; struct cl_attr *attr = &osc_env_info(env)->oti_attr; - unsigned valid; + unsigned int valid; valid = CAT_BLOCKS | CAT_ATIME | CAT_CTIME | CAT_MTIME | CAT_SIZE; if (!lvb) diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index 4bb3b45..fed4da6 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -134,8 +134,8 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], /* * Hash operations for uid/gid <-> osc_quota_info */ -static unsigned -oqi_hashfn(struct cfs_hash *hs, const void *key, unsigned mask) +static unsigned int +oqi_hashfn(struct cfs_hash *hs, const void *key, unsigned int mask) { return cfs_hash_u32_hash(*((__u32 *)key), mask); } diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 7b6fda5..7143564 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -908,9 +908,9 @@ static int check_write_rcs(struct ptlrpc_request *req, static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2) { if (p1->flag != p2->flag) { - unsigned mask = ~(OBD_BRW_FROM_GRANT | OBD_BRW_NOCACHE | - OBD_BRW_SYNC | OBD_BRW_ASYNC | - OBD_BRW_NOQUOTA | OBD_BRW_SOFT_SYNC); + unsigned int mask = ~(OBD_BRW_FROM_GRANT | OBD_BRW_NOCACHE | + OBD_BRW_SYNC | OBD_BRW_ASYNC | + OBD_BRW_NOQUOTA | OBD_BRW_SOFT_SYNC); /* warn if we try to combine flags that we don't know to be * safe to combine diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index 7b020d6..6c7c8b6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -152,8 +152,8 @@ void ptlrpc_connection_fini(void) /* * Hash operations for net_peer<->connection */ -static unsigned -conn_hashfn(struct cfs_hash *hs, const void *key, unsigned mask) +static unsigned int +conn_hashfn(struct cfs_hash *hs, const void *key, unsigned int mask) { return cfs_hash_djb2_hash(key, sizeof(lnet_process_id_t), mask); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 9bad57d..f874781 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -479,8 +479,8 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) struct ptlrpc_nrs_policy *policy; struct ptlrpc_nrs_pol_info *infos; struct ptlrpc_nrs_pol_info tmp; - unsigned num_pols; - unsigned pol_idx = 0; + unsigned int num_pols; + unsigned int pol_idx = 0; bool hp = false; int i; int rc = 0; diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index fc754e7..70c7055 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -343,9 +343,9 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, struct ptlrpc_service_conf *conf) { struct ptlrpc_service_thr_conf *tc = &conf->psc_thr; - unsigned init; - unsigned total; - unsigned nthrs; + unsigned int init; + unsigned int total; + unsigned int nthrs; int weight; /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index e12eb83..a04e36c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -195,25 +195,25 @@ void lustre_assert_wire_constants(void) LASSERTF(REINT_MAX == 10, "found %lld\n", (long long)REINT_MAX); LASSERTF(DISP_IT_EXECD == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)DISP_IT_EXECD); + (unsigned int)DISP_IT_EXECD); LASSERTF(DISP_LOOKUP_EXECD == 0x00000002UL, "found 0x%.8xUL\n", - (unsigned)DISP_LOOKUP_EXECD); + (unsigned int)DISP_LOOKUP_EXECD); LASSERTF(DISP_LOOKUP_NEG == 0x00000004UL, "found 0x%.8xUL\n", - (unsigned)DISP_LOOKUP_NEG); + (unsigned int)DISP_LOOKUP_NEG); LASSERTF(DISP_LOOKUP_POS == 0x00000008UL, "found 0x%.8xUL\n", - (unsigned)DISP_LOOKUP_POS); + (unsigned int)DISP_LOOKUP_POS); LASSERTF(DISP_OPEN_CREATE == 0x00000010UL, "found 0x%.8xUL\n", - (unsigned)DISP_OPEN_CREATE); + (unsigned int)DISP_OPEN_CREATE); LASSERTF(DISP_OPEN_OPEN == 0x00000020UL, "found 0x%.8xUL\n", - (unsigned)DISP_OPEN_OPEN); + (unsigned int)DISP_OPEN_OPEN); LASSERTF(DISP_ENQ_COMPLETE == 0x00400000UL, "found 0x%.8xUL\n", - (unsigned)DISP_ENQ_COMPLETE); + (unsigned int)DISP_ENQ_COMPLETE); LASSERTF(DISP_ENQ_OPEN_REF == 0x00800000UL, "found 0x%.8xUL\n", - (unsigned)DISP_ENQ_OPEN_REF); + (unsigned int)DISP_ENQ_OPEN_REF); LASSERTF(DISP_ENQ_CREATE_REF == 0x01000000UL, "found 0x%.8xUL\n", - (unsigned)DISP_ENQ_CREATE_REF); + (unsigned int)DISP_ENQ_CREATE_REF); LASSERTF(DISP_OPEN_LOCK == 0x02000000UL, "found 0x%.8xUL\n", - (unsigned)DISP_OPEN_LOCK); + (unsigned int)DISP_OPEN_LOCK); LASSERTF(MDS_STATUS_CONN == 1, "found %lld\n", (long long)MDS_STATUS_CONN); LASSERTF(MDS_STATUS_LOV == 2, "found %lld\n", @@ -400,13 +400,13 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct lustre_mdt_attrs *)0)->lma_self_fid) == 16, "found %lld\n", (long long)(int)sizeof(((struct lustre_mdt_attrs *)0)->lma_self_fid)); LASSERTF(LMAI_RELEASED == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)LMAI_RELEASED); + (unsigned int)LMAI_RELEASED); LASSERTF(LMAC_HSM == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)LMAC_HSM); + (unsigned int)LMAC_HSM); LASSERTF(LMAC_NOT_IN_OI == 0x00000004UL, "found 0x%.8xUL\n", - (unsigned)LMAC_NOT_IN_OI); + (unsigned int)LMAC_NOT_IN_OI); LASSERTF(LMAC_FID_ON_OST == 0x00000008UL, "found 0x%.8xUL\n", - (unsigned)LMAC_FID_ON_OST); + (unsigned int)LMAC_FID_ON_OST); /* Checks for struct ost_id */ LASSERTF((int)sizeof(struct ost_id) == 16, "found %lld\n", @@ -456,11 +456,11 @@ void lustre_assert_wire_constants(void) LASSERTF(FID_SEQ_LOV_DEFAULT == 0xffffffffffffffffULL, "found 0x%.16llxULL\n", (long long)FID_SEQ_LOV_DEFAULT); LASSERTF(FID_OID_SPECIAL_BFL == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)FID_OID_SPECIAL_BFL); + (unsigned int)FID_OID_SPECIAL_BFL); LASSERTF(FID_OID_DOT_LUSTRE == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)FID_OID_DOT_LUSTRE); + (unsigned int)FID_OID_DOT_LUSTRE); LASSERTF(FID_OID_DOT_LUSTRE_OBF == 0x00000002UL, "found 0x%.8xUL\n", - (unsigned)FID_OID_DOT_LUSTRE_OBF); + (unsigned int)FID_OID_DOT_LUSTRE_OBF); /* Checks for struct lu_dirent */ LASSERTF((int)sizeof(struct lu_dirent) == 32, "found %lld\n", @@ -490,11 +490,11 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct lu_dirent *)0)->lde_name[0]) == 1, "found %lld\n", (long long)(int)sizeof(((struct lu_dirent *)0)->lde_name[0])); LASSERTF(LUDA_FID == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)LUDA_FID); + (unsigned int)LUDA_FID); LASSERTF(LUDA_TYPE == 0x00000002UL, "found 0x%.8xUL\n", - (unsigned)LUDA_TYPE); + (unsigned int)LUDA_TYPE); LASSERTF(LUDA_64BITHASH == 0x00000004UL, "found 0x%.8xUL\n", - (unsigned)LUDA_64BITHASH); + (unsigned int)LUDA_64BITHASH); /* Checks for struct luda_type */ LASSERTF((int)sizeof(struct luda_type) == 2, "found %lld\n", @@ -820,41 +820,41 @@ void lustre_assert_wire_constants(void) LASSERTF(MSGHDR_CKSUM_INCOMPAT18 == 2, "found %lld\n", (long long)MSGHDR_CKSUM_INCOMPAT18); LASSERTF(MSG_OP_FLAG_MASK == 0xffff0000UL, "found 0x%.8xUL\n", - (unsigned)MSG_OP_FLAG_MASK); + (unsigned int)MSG_OP_FLAG_MASK); LASSERTF(MSG_OP_FLAG_SHIFT == 16, "found %lld\n", (long long)MSG_OP_FLAG_SHIFT); LASSERTF(MSG_GEN_FLAG_MASK == 0x0000ffffUL, "found 0x%.8xUL\n", - (unsigned)MSG_GEN_FLAG_MASK); + (unsigned int)MSG_GEN_FLAG_MASK); LASSERTF(MSG_LAST_REPLAY == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)MSG_LAST_REPLAY); + (unsigned int)MSG_LAST_REPLAY); LASSERTF(MSG_RESENT == 0x00000002UL, "found 0x%.8xUL\n", - (unsigned)MSG_RESENT); + (unsigned int)MSG_RESENT); LASSERTF(MSG_REPLAY == 0x00000004UL, "found 0x%.8xUL\n", - (unsigned)MSG_REPLAY); + (unsigned int)MSG_REPLAY); LASSERTF(MSG_DELAY_REPLAY == 0x00000010UL, "found 0x%.8xUL\n", - (unsigned)MSG_DELAY_REPLAY); + (unsigned int)MSG_DELAY_REPLAY); LASSERTF(MSG_VERSION_REPLAY == 0x00000020UL, "found 0x%.8xUL\n", - (unsigned)MSG_VERSION_REPLAY); + (unsigned int)MSG_VERSION_REPLAY); LASSERTF(MSG_REQ_REPLAY_DONE == 0x00000040UL, "found 0x%.8xUL\n", - (unsigned)MSG_REQ_REPLAY_DONE); + (unsigned int)MSG_REQ_REPLAY_DONE); LASSERTF(MSG_LOCK_REPLAY_DONE == 0x00000080UL, "found 0x%.8xUL\n", - (unsigned)MSG_LOCK_REPLAY_DONE); + (unsigned int)MSG_LOCK_REPLAY_DONE); LASSERTF(MSG_CONNECT_RECOVERING == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)MSG_CONNECT_RECOVERING); + (unsigned int)MSG_CONNECT_RECOVERING); LASSERTF(MSG_CONNECT_RECONNECT == 0x00000002UL, "found 0x%.8xUL\n", - (unsigned)MSG_CONNECT_RECONNECT); + (unsigned int)MSG_CONNECT_RECONNECT); LASSERTF(MSG_CONNECT_REPLAYABLE == 0x00000004UL, "found 0x%.8xUL\n", - (unsigned)MSG_CONNECT_REPLAYABLE); + (unsigned int)MSG_CONNECT_REPLAYABLE); LASSERTF(MSG_CONNECT_LIBCLIENT == 0x00000010UL, "found 0x%.8xUL\n", - (unsigned)MSG_CONNECT_LIBCLIENT); + (unsigned int)MSG_CONNECT_LIBCLIENT); LASSERTF(MSG_CONNECT_INITIAL == 0x00000020UL, "found 0x%.8xUL\n", - (unsigned)MSG_CONNECT_INITIAL); + (unsigned int)MSG_CONNECT_INITIAL); LASSERTF(MSG_CONNECT_ASYNC == 0x00000040UL, "found 0x%.8xUL\n", - (unsigned)MSG_CONNECT_ASYNC); + (unsigned int)MSG_CONNECT_ASYNC); LASSERTF(MSG_CONNECT_NEXT_VER == 0x00000080UL, "found 0x%.8xUL\n", - (unsigned)MSG_CONNECT_NEXT_VER); + (unsigned int)MSG_CONNECT_NEXT_VER); LASSERTF(MSG_CONNECT_TRANSNO == 0x00000100UL, "found 0x%.8xUL\n", - (unsigned)MSG_CONNECT_TRANSNO); + (unsigned int)MSG_CONNECT_TRANSNO); /* Checks for struct obd_connect_data */ LASSERTF((int)sizeof(struct obd_connect_data) == 192, "found %lld\n", @@ -1114,11 +1114,11 @@ void lustre_assert_wire_constants(void) LASSERTF(OBD_CONNECT_FLAGS2 == 0x8000000000000000ULL, "found 0x%.16llxULL\n", OBD_CONNECT_FLAGS2); LASSERTF(OBD_CKSUM_CRC32 == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)OBD_CKSUM_CRC32); + (unsigned int)OBD_CKSUM_CRC32); LASSERTF(OBD_CKSUM_ADLER == 0x00000002UL, "found 0x%.8xUL\n", - (unsigned)OBD_CKSUM_ADLER); + (unsigned int)OBD_CKSUM_ADLER); LASSERTF(OBD_CKSUM_CRC32C == 0x00000004UL, "found 0x%.8xUL\n", - (unsigned)OBD_CKSUM_CRC32C); + (unsigned int)OBD_CKSUM_CRC32C); /* Checks for struct obdo */ LASSERTF((int)sizeof(struct obdo) == 208, "found %lld\n", @@ -1428,13 +1428,13 @@ void lustre_assert_wire_constants(void) (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects[0])); CLASSERT(LOV_MAGIC_V3 == (0x0BD30000 | 0x0BD0)); LASSERTF(LOV_PATTERN_RAID0 == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)LOV_PATTERN_RAID0); + (unsigned int)LOV_PATTERN_RAID0); LASSERTF(LOV_PATTERN_RAID1 == 0x00000002UL, "found 0x%.8xUL\n", - (unsigned)LOV_PATTERN_RAID1); + (unsigned int)LOV_PATTERN_RAID1); LASSERTF(LOV_PATTERN_FIRST == 0x00000100UL, "found 0x%.8xUL\n", - (unsigned)LOV_PATTERN_FIRST); + (unsigned int)LOV_PATTERN_FIRST); LASSERTF(LOV_PATTERN_CMOBD == 0x00000200UL, "found 0x%.8xUL\n", - (unsigned)LOV_PATTERN_CMOBD); + (unsigned int)LOV_PATTERN_CMOBD); /* Checks for struct lmv_mds_md_v1 */ LASSERTF((int)sizeof(struct lmv_mds_md_v1) == 56, "found %lld\n", @@ -4133,9 +4133,9 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct hsm_request *)0)->hr_data_len) == 4, "found %lld\n", (long long)(int)sizeof(((struct hsm_request *)0)->hr_data_len)); LASSERTF(HSM_FORCE_ACTION == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)HSM_FORCE_ACTION); + (unsigned int)HSM_FORCE_ACTION); LASSERTF(HSM_GHOST_COPY == 0x00000002UL, "found 0x%.8xUL\n", - (unsigned)HSM_GHOST_COPY); + (unsigned int)HSM_GHOST_COPY); /* Checks for struct hsm_user_request */ LASSERTF((int)sizeof(struct hsm_user_request) == 24, "found %lld\n", -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 04:57:35 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Tue, 6 Dec 2016 23:57:35 -0500 Subject: [lustre-devel] [PATCH 0/5] Lustre style fixes Message-ID: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> These patches fix some more of the low hanging fruits in the style problems highlighted by checkpatch. Now only false positive ERRORs are left. This also converts all bare unsigneds into unsigned ints and a couple of spelling fixes. Please consider. Oleg Drokin (5): staging/lustre/o2iblnd: Add missing space staging/lustre/socklnd: Fix whitespace problem staging/lustre: Convert all bare unsigned to unsigned int staging/lustre/o2iblnd: Fix misspelling intialized->intialized staging/lustre/o2iblnd: Fix misspelled attemps->attempts drivers/staging/lustre/include/linux/lnet/lnetst.h | 6 +- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 4 +- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 4 +- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 2 +- .../staging/lustre/lustre/include/lprocfs_status.h | 3 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 8 +- drivers/staging/lustre/lustre/llite/llite_nfs.c | 2 +- drivers/staging/lustre/lustre/llite/rw26.c | 4 +- drivers/staging/lustre/lustre/llite/xattr_cache.c | 6 +- drivers/staging/lustre/lustre/lov/lov_pool.c | 3 +- .../lustre/lustre/obdclass/lprocfs_status.c | 3 +- drivers/staging/lustre/lustre/obdclass/lu_object.c | 6 +- .../staging/lustre/lustre/obdclass/obd_config.c | 4 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 2 +- drivers/staging/lustre/lustre/osc/osc_quota.c | 4 +- drivers/staging/lustre/lustre/osc/osc_request.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/connection.c | 4 +- .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 92 +++++++++++----------- 20 files changed, 88 insertions(+), 85 deletions(-) -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 04:57:39 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Tue, 6 Dec 2016 23:57:39 -0500 Subject: [lustre-devel] [PATCH 4/5] staging/lustre/o2iblnd: Fix misspelling intialized->intialized In-Reply-To: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> References: <1481086660-1610943-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481086660-1610943-5-git-send-email-green@linuxhacker.ru> Highlighted by checkpatch: + if (!ps->ps_net) /* intialized? */ Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index e2fc65f..7f761b3 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -1489,7 +1489,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps, static void kiblnd_fail_fmr_poolset(struct kib_fmr_poolset *fps, struct list_head *zombies) { - if (!fps->fps_net) /* intialized? */ + if (!fps->fps_net) /* initialized? */ return; spin_lock(&fps->fps_lock); @@ -1812,7 +1812,7 @@ static void kiblnd_destroy_pool_list(struct list_head *head) static void kiblnd_fail_poolset(struct kib_poolset *ps, struct list_head *zombies) { - if (!ps->ps_net) /* intialized? */ + if (!ps->ps_net) /* initialized? */ return; spin_lock(&ps->ps_lock); -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 05:39:27 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 00:39:27 -0500 Subject: [lustre-devel] [PATCH] staging/lustre/lnetselftest: Fix potential integer overflow Message-ID: <1481089167-1674826-1-git-send-email-green@linuxhacker.ru> It looks like if the passed in parameter is not present, but parameter length is non zero, then sanity checks on the length are skipped and lstcon_test_add() might then use incorrect allocation that's prone to integer overflow size. This patch ensures that parameter len is zero if parameter is not present. Reported-by: Dan Carpenter Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lnet/selftest/conctl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c index 02847bf..9438302 100644 --- a/drivers/staging/lustre/lnet/selftest/conctl.c +++ b/drivers/staging/lustre/lnet/selftest/conctl.c @@ -742,6 +742,10 @@ static int lst_test_add_ioctl(lstio_test_args_t *args) PAGE_SIZE - sizeof(struct lstcon_test))) return -EINVAL; + /* Enforce zero parameter length if there's no parameter */ + if (!args->lstio_tes_param && args->lstio_tes_param_len) + return -EINVAL; + LIBCFS_ALLOC(batch_name, args->lstio_tes_bat_nmlen + 1); if (!batch_name) return rc; -- 2.7.4 From gregkh at linuxfoundation.org Wed Dec 7 10:40:43 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Wed, 7 Dec 2016 11:40:43 +0100 Subject: [lustre-devel] [PATCH] staging/lustre/osc: Revert erroneous list_for_each_entry_safe use In-Reply-To: <1481082828-1590398-1-git-send-email-green@linuxhacker.ru> References: <1481082828-1590398-1-git-send-email-green@linuxhacker.ru> Message-ID: <20161207104043.GA21689@kroah.com> On Tue, Dec 06, 2016 at 10:53:48PM -0500, Oleg Drokin wrote: > I have been having a lot of unexplainable crashes in osc_lru_shrink > lately that I could not see a good explanation for and then I found > this patch that slip under the radar somehow that incorrectly > converted while loop for lru list iteration into > list_for_each_entry_safe totally ignoring that in the body of > the loop we drop spinlocks guarding this list and move list entries > around. > Not sure why it was not showing up right away, perhaps some of the > more recent LRU changes committed caused some extra pressure on this > code that finally highlighted the breakage. > > Reverts: 8adddc36b1fc ("staging: lustre: osc: Use list_for_each_entry_safe") > CC: Bhaktipriya Shridhar > Signed-off-by: Oleg Drokin > --- > I also do not see this patch in any of the mailing lists I am subscribed to. > I wonder if there's a way to subscribe to those Greg's > "This is a note to let you know that I've just added the patch ...." > emails that concern Lustre to get them even if I am not on the CC list in > the patch itself? This came in from the Outreacy application process, which now requires that they cc: the maintainers to catch this type of issue. So you should have seen these types of patches this last round, the commit you reference was done before that change happened, sorry. This change should go to stable kernels, so I'll mark it that way. thanks, greg k-h From lambert.quentin at gmail.com Wed Dec 7 15:20:06 2016 From: lambert.quentin at gmail.com (Quentin Lambert) Date: Wed, 7 Dec 2016 16:20:06 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <81821426-c32c-c45a-e9a3-82f9818fc986@gmail.com> References: <20161202173332.5100-1-lambert.quentin@gmail.com> <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> <81821426-c32c-c45a-e9a3-82f9818fc986@gmail.com> Message-ID: <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> Hi all, I am looking at the drivers/staging/lustre/lustre/llite/dir.c: 1469 /* Call mdc_iocontrol */ 1470 rc = obd_iocontrol(LL_IOC_FID2MDTIDX, exp, sizeof(fid), &fid, 1471 &index); 1472 if (rc) and sparse says: drivers/staging/lustre/lustre/llite/dir.c:1471:37: warning: incorrect type in argument 5 (different address spaces) I was wondering if there was any value to add a cast to fix the warning? And I guess this solution would also apply in my original patch to drivers/staging/lustre/lnet/lnet/lib-socket.c Quentin From dan.carpenter at oracle.com Wed Dec 7 15:32:14 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 7 Dec 2016 18:32:14 +0300 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> References: <20161202173332.5100-1-lambert.quentin@gmail.com> <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> <81821426-c32c-c45a-e9a3-82f9818fc986@gmail.com> <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> Message-ID: <20161207153214.GN8176@mwanda> On Wed, Dec 07, 2016 at 04:20:06PM +0100, Quentin Lambert wrote: > Hi all, > > I am looking at the drivers/staging/lustre/lustre/llite/dir.c: > > 1469 /* Call mdc_iocontrol */ > 1470 rc = obd_iocontrol(LL_IOC_FID2MDTIDX, exp, > sizeof(fid), &fid, > 1471 &index); > 1472 if (rc) > > and sparse says: > > drivers/staging/lustre/lustre/llite/dir.c:1471:37: warning: > incorrect type in argument 5 (different address spaces) > > I was wondering if there was any value to add a cast to fix the warning? > And I guess this solution would also apply in my original patch to > > drivers/staging/lustre/lnet/lnet/lib-socket.c Just leave these alone until someone can come clean it up properly. Warnings are good! People have spent years and years to create programs to print warnings. Don't silence the warning by adding a cast. The warning means show that the code is dangerous. regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 7 15:33:17 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 7 Dec 2016 18:33:17 +0300 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> References: <20161202173332.5100-1-lambert.quentin@gmail.com> <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> <81821426-c32c-c45a-e9a3-82f9818fc986@gmail.com> <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> Message-ID: <20161207153317.GO8176@mwanda> Lustre is kind of a mess with regards to keeping user and kernel pointers separate. It's not going to be easy to fix. regards, dan carpenter From lambert.quentin at gmail.com Wed Dec 7 15:42:30 2016 From: lambert.quentin at gmail.com (Quentin Lambert) Date: Wed, 7 Dec 2016 16:42:30 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <20161207153317.GO8176@mwanda> References: <20161202173332.5100-1-lambert.quentin@gmail.com> <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> <81821426-c32c-c45a-e9a3-82f9818fc986@gmail.com> <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> <20161207153317.GO8176@mwanda> Message-ID: <46ee428d-016f-e532-9824-4ddbe8a0cc8b@gmail.com> On 12/07/2016 04:33 PM, Dan Carpenter wrote: > Lustre is kind of a mess with regards to keeping user and kernel > pointers separate. It's not going to be easy to fix. Fair enough. I am trying to make a contribution to drivers/staging using sparse. With that in mind, do you still fill I should keep clear of lustre? I feel that actually doing the work properly could be a meaningful learning experience. I start to understand now, that what I was proposing before was more of a hack than a solution and would have resulted in hiding meaningful infos. Quentin From green at linuxhacker.ru Wed Dec 7 16:29:36 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 11:29:36 -0500 Subject: [lustre-devel] [PATCH] staging/lustre/osc: Revert erroneous list_for_each_entry_safe use In-Reply-To: <20161207104043.GA21689@kroah.com> References: <1481082828-1590398-1-git-send-email-green@linuxhacker.ru> <20161207104043.GA21689@kroah.com> Message-ID: On Dec 7, 2016, at 5:40 AM, Greg Kroah-Hartman wrote: > On Tue, Dec 06, 2016 at 10:53:48PM -0500, Oleg Drokin wrote: >> I have been having a lot of unexplainable crashes in osc_lru_shrink >> lately that I could not see a good explanation for and then I found >> this patch that slip under the radar somehow that incorrectly >> converted while loop for lru list iteration into >> list_for_each_entry_safe totally ignoring that in the body of >> the loop we drop spinlocks guarding this list and move list entries >> around. >> Not sure why it was not showing up right away, perhaps some of the >> more recent LRU changes committed caused some extra pressure on this >> code that finally highlighted the breakage. >> >> Reverts: 8adddc36b1fc ("staging: lustre: osc: Use list_for_each_entry_safe") >> CC: Bhaktipriya Shridhar >> Signed-off-by: Oleg Drokin >> --- >> I also do not see this patch in any of the mailing lists I am subscribed to. >> I wonder if there's a way to subscribe to those Greg's >> "This is a note to let you know that I've just added the patch ...." >> emails that concern Lustre to get them even if I am not on the CC list in >> the patch itself? > > This came in from the Outreacy application process, which now requires > that they cc: the maintainers to catch this type of issue. So you > should have seen these types of patches this last round, the commit you > reference was done before that change happened, sorry. Do you know approximate date range of when these patches ere sneaking in? I'd like to take a look at the rest of it proactively just to see if there are more undiscovered surprises? > This change should go to stable kernels, so I'll mark it that way. Thanks! From oleg.drokin at intel.com Wed Dec 7 17:10:10 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Wed, 7 Dec 2016 12:10:10 -0500 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <20161207153317.GO8176@mwanda> References: <20161202173332.5100-1-lambert.quentin@gmail.com> <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> <81821426-c32c-c45a-e9a3-82f9818fc986@gmail.com> <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> <20161207153317.GO8176@mwanda> Message-ID: On Dec 7, 2016, at 10:33 AM, Dan Carpenter wrote: > Lustre is kind of a mess with regards to keeping user and kernel > pointers separate. It's not going to be easy to fix. Actually I believe I made significant inroads in properly cleaning (almost?) everything in this area about a year ago (to the point that only false positives were left). I guess some more stuff crept in, I'll just make another run through and see what else I can improve. From oleg.drokin at intel.com Wed Dec 7 17:22:41 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Wed, 7 Dec 2016 12:22:41 -0500 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> References: <20161202173332.5100-1-lambert.quentin@gmail.com> <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> <81821426-c32c-c45a-e9a3-82f9818fc986@gmail.com> <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> Message-ID: <92C79E56-E447-46CB-9D4C-ECC862F2B43E@intel.com> On Dec 7, 2016, at 10:20 AM, Quentin Lambert wrote: > Hi all, > > I am looking at the drivers/staging/lustre/lustre/llite/dir.c: > > 1469 /* Call mdc_iocontrol */ > 1470 rc = obd_iocontrol(LL_IOC_FID2MDTIDX, exp, sizeof(fid), &fid, > 1471 &index); > 1472 if (rc) > > and sparse says: > > drivers/staging/lustre/lustre/llite/dir.c:1471:37: warning: incorrect type in argument 5 (different address spaces) > > I was wondering if there was any value to add a cast to fix the warning? These's a sister warning to this one, btw, in drivers/staging/lustre/lustre/lmv/lmv_obd.c:996:19: warning: cast removes address space of expression It is an ugly kludge and I guess needs to just be reworked somehow instead to avoid these ugly games. From jsimmons at infradead.org Wed Dec 7 19:05:28 2016 From: jsimmons at infradead.org (James Simmons) Date: Wed, 7 Dec 2016 19:05:28 +0000 (GMT) Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> <20161203085550.GA5375@kroah.com> <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> Message-ID: > On Dec 3, 2016, at 3:55 AM, gregkh at linuxfoundation.org wrote: > > > On Fri, Dec 02, 2016 at 09:53:08PM +0000, Dilger, Andreas wrote: > >> Al, > >> Greg recently raised the issue of what still needs to be done to > >> move the Lustre code out of staging/ and into the fs/ tree. > >> > >> James has been doing a great job of cleaning up various checkpatch > >> issues and keeping the code updated with the latest fixes, but we > >> were wondering what you were aware of that needed to be cleaned > >> up in Lustre? > > > > Is the whole "mixing kernel structures in userspace structures" all > > resolved now? For some reason I thought that you had kernel locks being > > passed to userspace and then back into the kernel, but it's been a long > > time since I last looked... > > While we certainly had our share of mixing user/kernelspace structures, > I don't think we ever passed anything with locks around back and forth. I think he means the use of linux list structures as a parameter for the ioctls in LNet selftest. The work is being done under: https://jira.hpdd.intel.com/browse/LU-8915 No patch ready just yet. From jsimmons at infradead.org Wed Dec 7 19:13:17 2016 From: jsimmons at infradead.org (James Simmons) Date: Wed, 7 Dec 2016 19:13:17 +0000 (GMT) Subject: [lustre-devel] [PATCH 3/6] staging: lustre: obdclass: Create a header for obdo related functions In-Reply-To: <20161206093635.GA11009@kroah.com> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> <1480707650-24089-4-git-send-email-jsimmons@infradead.org> <20161206093635.GA11009@kroah.com> Message-ID: > On Fri, Dec 02, 2016 at 02:40:47PM -0500, James Simmons wrote: > > From: Ben Evans > > > > Remove all obdo related functions from lustre_idl.h > > Create lustre_odbo.h. Include where appropriate. > > Make the functions lustre_get_wire_obdo and > > lustre_set_wire_obdo to not be inlined functions. > > Breaks the build, please test better. I'm dropping this, and the rest > of this series from my queue :( Oops. Send a earlier verison of the patch by mistake. > > greg k-h > From jsimmons at infradead.org Wed Dec 7 19:18:36 2016 From: jsimmons at infradead.org (James Simmons) Date: Wed, 7 Dec 2016 19:18:36 +0000 (GMT) Subject: [lustre-devel] [PATCH 3/6] staging: lustre: obdclass: Create a header for obdo related functions In-Reply-To: <20161205220647.GD8244@mwanda> References: <1480707650-24089-1-git-send-email-jsimmons@infradead.org> <1480707650-24089-4-git-send-email-jsimmons@infradead.org> <20161205205005.GA31243@mwanda> <2394CAB0-41C1-4F3B-AF94-03D302F6ABF5@intel.com> <20161205220647.GD8244@mwanda> Message-ID: > Sorry, I was unclear. I have no problem with white space changes on > their own or when they are on the same line as something else you're > changing. > > What I meant is that when you're just moving functions around then don't > mix unrelated white space changes into that patch. I have automated > scripts for reviewing moving code around but slight changes mean that I > have to review it manually line by line to spot the difference. I can > review a one liner cleanup in about 10 seconds but it's finding the line > which changed that's the problem in this case. > > And I'm also fine with this patch since I already reviewed it, but in > the future, please avoid the temptation to do cleanups until after. Okay, I can do that. I was just trying to create checkpatch clean patches. From dan.carpenter at oracle.com Wed Dec 7 19:22:37 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 7 Dec 2016 22:22:37 +0300 Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <46ee428d-016f-e532-9824-4ddbe8a0cc8b@gmail.com> References: <20161202173332.5100-1-lambert.quentin@gmail.com> <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> <81821426-c32c-c45a-e9a3-82f9818fc986@gmail.com> <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> <20161207153317.GO8176@mwanda> <46ee428d-016f-e532-9824-4ddbe8a0cc8b@gmail.com> Message-ID: <20161207192237.GP8176@mwanda> On Wed, Dec 07, 2016 at 04:42:30PM +0100, Quentin Lambert wrote: > > > On 12/07/2016 04:33 PM, Dan Carpenter wrote: > >Lustre is kind of a mess with regards to keeping user and kernel > >pointers separate. It's not going to be easy to fix. > Fair enough. > I am trying to make a contribution to drivers/staging using sparse. > With that in mind, do you still fill I should keep clear of lustre? > I feel that actually doing the work properly could be a meaningful > learning experience. It's just that you're the fifth person to look at lustre __user annotations and it doesn't end well. You need to be a lustre expert who can test things. But for other lustre things, feel free. regards, dan carpenter From jsimmons at infradead.org Wed Dec 7 19:52:39 2016 From: jsimmons at infradead.org (James Simmons) Date: Wed, 7 Dec 2016 19:52:39 +0000 (GMT) Subject: [lustre-devel] [PATCH] staging: lustre: Fix a spatch warning due to an assignment from kernel to user space In-Reply-To: <20161207192237.GP8176@mwanda> References: <20161202173332.5100-1-lambert.quentin@gmail.com> <306D1D4D-A949-44F6-BAFE-44F08F609D9B@intel.com> <81821426-c32c-c45a-e9a3-82f9818fc986@gmail.com> <33d23121-e5ca-0e14-bfbb-632f883e0948@gmail.com> <20161207153317.GO8176@mwanda> <46ee428d-016f-e532-9824-4ddbe8a0cc8b@gmail.com> <20161207192237.GP8176@mwanda> Message-ID: > > On 12/07/2016 04:33 PM, Dan Carpenter wrote: > > >Lustre is kind of a mess with regards to keeping user and kernel > > >pointers separate. It's not going to be easy to fix. > > Fair enough. > > I am trying to make a contribution to drivers/staging using sparse. > > With that in mind, do you still fill I should keep clear of lustre? > > I feel that actually doing the work properly could be a meaningful > > learning experience. > > It's just that you're the fifth person to look at lustre __user > annotations and it doesn't end well. You need to be a lustre expert > who can test things. > > But for other lustre things, feel free. Actually we are working to fix this issue. We are working on a process that lustre patch posted here get sucked up and put into our test harness automatically. It needs more love but its coming along. From jsimmons at infradead.org Wed Dec 7 19:57:13 2016 From: jsimmons at infradead.org (James Simmons) Date: Wed, 7 Dec 2016 19:57:13 +0000 (GMT) Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> <20161203085550.GA5375@kroah.com> <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> <20161206161524.GA5535@kroah.com> <7AF464A9-1D0F-48E9-B83C-66F983268473@intel.com> Message-ID: > > On the warning front, we have 879 line over 80 characters, but a bunch > > of those are due to long error messages that we cannot split into a multiline thing anyway. > > 71 Prefer 'unsigned int' to bare use of 'unsigned' that is a relatively new one > > 22 new typedefs (all in lnet, I drove out all the lustre ones, so I guess I can tackle these too). > > I think James already has a patch series getting rid of typedefs from LNet? I created a big patch some time ago but I need to break it into smaller pieces. We should sync our tools to be able to build against these changes as well. I pushed patches to change our tools. From gregkh at linuxfoundation.org Wed Dec 7 20:37:42 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Wed, 7 Dec 2016 21:37:42 +0100 Subject: [lustre-devel] [PATCH] staging/lustre/osc: Revert erroneous list_for_each_entry_safe use In-Reply-To: References: <1481082828-1590398-1-git-send-email-green@linuxhacker.ru> <20161207104043.GA21689@kroah.com> Message-ID: <20161207203742.GA18474@kroah.com> On Wed, Dec 07, 2016 at 11:29:36AM -0500, Oleg Drokin wrote: > > On Dec 7, 2016, at 5:40 AM, Greg Kroah-Hartman wrote: > > > On Tue, Dec 06, 2016 at 10:53:48PM -0500, Oleg Drokin wrote: > >> I have been having a lot of unexplainable crashes in osc_lru_shrink > >> lately that I could not see a good explanation for and then I found > >> this patch that slip under the radar somehow that incorrectly > >> converted while loop for lru list iteration into > >> list_for_each_entry_safe totally ignoring that in the body of > >> the loop we drop spinlocks guarding this list and move list entries > >> around. > >> Not sure why it was not showing up right away, perhaps some of the > >> more recent LRU changes committed caused some extra pressure on this > >> code that finally highlighted the breakage. > >> > >> Reverts: 8adddc36b1fc ("staging: lustre: osc: Use list_for_each_entry_safe") > >> CC: Bhaktipriya Shridhar > >> Signed-off-by: Oleg Drokin > >> --- > >> I also do not see this patch in any of the mailing lists I am subscribed to. > >> I wonder if there's a way to subscribe to those Greg's > >> "This is a note to let you know that I've just added the patch ...." > >> emails that concern Lustre to get them even if I am not on the CC list in > >> the patch itself? > > > > This came in from the Outreacy application process, which now requires > > that they cc: the maintainers to catch this type of issue. So you > > should have seen these types of patches this last round, the commit you > > reference was done before that change happened, sorry. > > Do you know approximate date range of when these patches ere sneaking in? Anytime before a few months ago. > I'd like to take a look at the rest of it proactively just to see if there are > more undiscovered surprises? If your testing isn't finding any problems, all should be good, right? :) From green at linuxhacker.ru Wed Dec 7 21:17:27 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 16:17:27 -0500 Subject: [lustre-devel] [PATCH] staging/lustre/osc: Revert erroneous list_for_each_entry_safe use In-Reply-To: <20161207203742.GA18474@kroah.com> References: <1481082828-1590398-1-git-send-email-green@linuxhacker.ru> <20161207104043.GA21689@kroah.com> <20161207203742.GA18474@kroah.com> Message-ID: <2FD5230F-C811-4F1B-AAB6-8907D8019F0D@linuxhacker.ru> On Dec 7, 2016, at 3:37 PM, Greg Kroah-Hartman wrote: > On Wed, Dec 07, 2016 at 11:29:36AM -0500, Oleg Drokin wrote: >> >> On Dec 7, 2016, at 5:40 AM, Greg Kroah-Hartman wrote: >> >>> On Tue, Dec 06, 2016 at 10:53:48PM -0500, Oleg Drokin wrote: >>>> I have been having a lot of unexplainable crashes in osc_lru_shrink >>>> lately that I could not see a good explanation for and then I found >>>> this patch that slip under the radar somehow that incorrectly >>>> converted while loop for lru list iteration into >>>> list_for_each_entry_safe totally ignoring that in the body of >>>> the loop we drop spinlocks guarding this list and move list entries >>>> around. >>>> Not sure why it was not showing up right away, perhaps some of the >>>> more recent LRU changes committed caused some extra pressure on this >>>> code that finally highlighted the breakage. >>>> >>>> Reverts: 8adddc36b1fc ("staging: lustre: osc: Use list_for_each_entry_safe") >>>> CC: Bhaktipriya Shridhar >>>> Signed-off-by: Oleg Drokin >>>> --- >>>> I also do not see this patch in any of the mailing lists I am subscribed to. >>>> I wonder if there's a way to subscribe to those Greg's >>>> "This is a note to let you know that I've just added the patch ...." >>>> emails that concern Lustre to get them even if I am not on the CC list in >>>> the patch itself? >>> >>> This came in from the Outreacy application process, which now requires >>> that they cc: the maintainers to catch this type of issue. So you >>> should have seen these types of patches this last round, the commit you >>> reference was done before that change happened, sorry. >> >> Do you know approximate date range of when these patches ere sneaking in? > > Anytime before a few months ago. Ugh, I see. >> I'd like to take a look at the rest of it proactively just to see if there are >> more undiscovered surprises? > > If your testing isn't finding any problems, all should be good, right? > :) I see processes hanging waiting for RPC response (rarely) that is very suspicious, but I did not get to the root of it yet. Also my test system is limited in capacity, they don't let me anywhere near those TOP100 systems with the staging client ;) From green at linuxhacker.ru Wed Dec 7 22:41:28 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 17:41:28 -0500 Subject: [lustre-devel] [PATCH 2/8] staging/lustre/ldlm: Correct itree_overlap_cb return type In-Reply-To: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481150494-1853127-3-git-send-email-green@linuxhacker.ru> As per interval_search() prototype, the callback should return enum, not int. This fixes correspondign sparse warning. Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index a4a291a..f4cbc89 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1148,7 +1148,7 @@ static int lock_matches(struct ldlm_lock *lock, struct lock_match_data *data) return INTERVAL_ITER_STOP; } -static unsigned int itree_overlap_cb(struct interval_node *in, void *args) +static enum interval_iter itree_overlap_cb(struct interval_node *in, void *args) { struct ldlm_interval *node = to_ldlm_interval(in); struct lock_match_data *data = args; -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 22:41:30 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 17:41:30 -0500 Subject: [lustre-devel] [PATCH 4/8] staging/lustre/lov: make lov_lsm_alloc() static In-Reply-To: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481150494-1853127-5-git-send-email-green@linuxhacker.ru> It's not used anywhere outside of this file. Highlighted by sparse. Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/lov/lov_pack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 6c93d18..68fa2de 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -198,7 +198,8 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count) return rc; } -struct lov_stripe_md *lov_lsm_alloc(u16 stripe_count, u32 pattern, u32 magic) +static struct lov_stripe_md *lov_lsm_alloc(u16 stripe_count, u32 pattern, + u32 magic) { struct lov_stripe_md *lsm; unsigned int i; -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 22:41:26 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 17:41:26 -0500 Subject: [lustre-devel] [PATCH 0/8] Sparse warning fixes in Lustre. Message-ID: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> This set of fixes aims at sparse warnings. Most of the patches are just moving declarations around to deal with the warning: symbol 'xxx' was not declared. Should it be static? kind of messages. Also a screwup with root_squash sysfs control is fixed. Oleg Drokin (8): staging/lustre/llite: move root_squash from sysfs to debugfs staging/lustre/ldlm: Correct itree_overlap_cb return type staging/lustre/llite: mark ll_io_init() static staging/lustre/lov: make lov_lsm_alloc() static staging/lustre/osc: extern declare osc_caches in a header staging/lustre: Declare lu_context/session_tags_default staging/lustre: Move lov_read_and_clear_async_rc declaration staging/lustre/ptlrpc: Move nrs_conf_fifo extern to a header drivers/staging/lustre/lustre/include/lu_object.h | 3 +++ drivers/staging/lustre/lustre/include/obd.h | 3 +++ drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- drivers/staging/lustre/lustre/llite/file.c | 2 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 27 ++++++++++++---------- drivers/staging/lustre/lustre/llite/vvp_internal.h | 2 -- drivers/staging/lustre/lustre/lov/lov_pack.c | 3 ++- drivers/staging/lustre/lustre/obdclass/cl_object.c | 3 +-- drivers/staging/lustre/lustre/osc/osc_internal.h | 2 ++ drivers/staging/lustre/lustre/osc/osc_request.c | 2 -- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 3 --- .../staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 3 +++ 12 files changed, 31 insertions(+), 24 deletions(-) -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 22:41:27 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 17:41:27 -0500 Subject: [lustre-devel] [PATCH 1/8] staging/lustre/llite: move root_squash from sysfs to debugfs In-Reply-To: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481150494-1853127-2-git-send-email-green@linuxhacker.ru> root_squash control got accidentally moved to sysfs instead of debugfs, and the write side of it was also broken expecting a userspace buffer. It contains both uid and gid values in a single file, so debugfs is a clear place for it. Reported-by: Al Viro Fixes: c948390f10ccc "fix inconsistencies of root squash feature" Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 27 +++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 03682c1..f3ee584 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -924,27 +924,29 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file, } LPROC_SEQ_FOPS(ll_unstable_stats); -static ssize_t root_squash_show(struct kobject *kobj, struct attribute *attr, - char *buf) +static int ll_root_squash_seq_show(struct seq_file *m, void *v) { - struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + struct super_block *sb = m->private; + struct ll_sb_info *sbi = ll_s2sbi(sb); struct root_squash_info *squash = &sbi->ll_squash; - return sprintf(buf, "%u:%u\n", squash->rsi_uid, squash->rsi_gid); + seq_printf(m, "%u:%u\n", squash->rsi_uid, squash->rsi_gid); + return 0; } -static ssize_t root_squash_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, size_t count) +static ssize_t ll_root_squash_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { - struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); + struct seq_file *m = file->private_data; + struct super_block *sb = m->private; + struct ll_sb_info *sbi = ll_s2sbi(sb); struct root_squash_info *squash = &sbi->ll_squash; return lprocfs_wr_root_squash(buffer, count, squash, - ll_get_fsname(sbi->ll_sb, NULL, 0)); + ll_get_fsname(sb, NULL, 0)); } -LUSTRE_RW_ATTR(root_squash); +LPROC_SEQ_FOPS(ll_root_squash); static int ll_nosquash_nids_seq_show(struct seq_file *m, void *v) { @@ -997,6 +999,8 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, { "unstable_stats", &ll_unstable_stats_fops, NULL }, { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, + { .name = "root_squash", + .fops = &ll_root_squash_fops }, { .name = "nosquash_nids", .fops = &ll_nosquash_nids_fops }, { NULL } @@ -1027,7 +1031,6 @@ static struct attribute *llite_attrs[] = { &lustre_attr_max_easize.attr, &lustre_attr_default_easize.attr, &lustre_attr_xattr_cache.attr, - &lustre_attr_root_squash.attr, NULL, }; -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 22:41:31 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 17:41:31 -0500 Subject: [lustre-devel] [PATCH 5/8] staging/lustre/osc: extern declare osc_caches in a header In-Reply-To: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481150494-1853127-6-git-send-email-green@linuxhacker.ru> This avoids frowned upon extern in the C file, and also shuts down a sparse warning of drivers/staging/lustre/lustre/osc/osc_dev.c:55:22: warning: symbol 'osc_caches' was not declared. Should it be static? Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/osc/osc_internal.h | 2 ++ drivers/staging/lustre/lustre/osc/osc_request.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 688783d..5cce82b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -181,6 +181,8 @@ static inline struct osc_device *obd2osc_dev(const struct obd_device *d) return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev); } +extern struct lu_kmem_descr osc_caches[]; + extern struct kmem_cache *osc_quota_kmem; struct osc_quota_info { /** linkage for quota hash table */ diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 7143564..f691297 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2766,8 +2766,6 @@ static struct obd_ops osc_obd_ops = { .quotactl = osc_quotactl, }; -extern struct lu_kmem_descr osc_caches[]; - static int __init osc_init(void) { struct lprocfs_static_vars lvars = { NULL }; -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 22:41:29 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 17:41:29 -0500 Subject: [lustre-devel] [PATCH 3/8] staging/lustre/llite: mark ll_io_init() static In-Reply-To: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481150494-1853127-4-git-send-email-green@linuxhacker.ru> It's not used anywhere out of this file. Highlighted by sparse. Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/llite/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index f634c11..d93f06a 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1016,7 +1016,7 @@ static bool file_is_noatime(const struct file *file) return false; } -void ll_io_init(struct cl_io *io, const struct file *file, int write) +static void ll_io_init(struct cl_io *io, const struct file *file, int write) { struct inode *inode = file_inode(file); -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 22:41:32 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 17:41:32 -0500 Subject: [lustre-devel] [PATCH 6/8] staging/lustre: Declare lu_context/session_tags_default In-Reply-To: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481150494-1853127-7-git-send-email-green@linuxhacker.ru> Make the declaration in a header, not as an extern in a C file, that is frowned upon. This also makes sparse a little bit more happy. Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/include/lu_object.h | 3 +++ drivers/staging/lustre/lustre/obdclass/cl_object.c | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 260643e..69b2812 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -1326,5 +1326,8 @@ void lu_buf_realloc(struct lu_buf *buf, size_t size); int lu_buf_check_and_grow(struct lu_buf *buf, size_t len); struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, size_t len); +extern __u32 lu_context_tags_default; +extern __u32 lu_session_tags_default; + /** @} lu */ #endif /* __LUSTRE_LU_OBJECT_H */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index f5d4e23..703cb67 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -54,6 +54,7 @@ #include #include "../../include/linux/libcfs/libcfs_hash.h" /* for cfs_hash stuff */ #include "../include/cl_object.h" +#include "../include/lu_object.h" #include "cl_internal.h" static struct kmem_cache *cl_env_kmem; @@ -61,8 +62,6 @@ static struct kmem_cache *cl_env_kmem; /** Lock class of cl_object_header::coh_attr_guard */ static struct lock_class_key cl_attr_guard_class; -extern __u32 lu_context_tags_default; -extern __u32 lu_session_tags_default; /** * Initialize cl_object_header. */ -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 22:41:34 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 17:41:34 -0500 Subject: [lustre-devel] [PATCH 8/8] staging/lustre/ptlrpc: Move nrs_conf_fifo extern to a header In-Reply-To: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481150494-1853127-9-git-send-email-green@linuxhacker.ru> This avoids having an extern definition in a C file which is bad, and also silences sparse complaint as well. Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 3 --- drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 7b6ffb1..ef19dbe 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -1559,9 +1559,6 @@ int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc, return rc; } -/* ptlrpc/nrs_fifo.c */ -extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; - /** * Adds all policies that ship with the ptlrpc module, to NRS core's list of * policies \e nrs_core.nrs_policies. diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index e0f859c..8e6a805 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -226,6 +226,9 @@ struct ptlrpc_nrs_policy *nrs_request_policy(struct ptlrpc_nrs_request *nrq) sizeof(NRS_LPROCFS_QUANTUM_NAME_REG __stringify(LPROCFS_NRS_QUANTUM_MAX) " " \ NRS_LPROCFS_QUANTUM_NAME_HP __stringify(LPROCFS_NRS_QUANTUM_MAX)) +/* ptlrpc/nrs_fifo.c */ +extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; + /* recovd_thread.c */ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink); -- 2.7.4 From green at linuxhacker.ru Wed Dec 7 22:41:33 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Wed, 7 Dec 2016 17:41:33 -0500 Subject: [lustre-devel] [PATCH 7/8] staging/lustre: Move lov_read_and_clear_async_rc declaration In-Reply-To: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> Message-ID: <1481150494-1853127-8-git-send-email-green@linuxhacker.ru> Move it to obd.h, so that it's included from both the users and the actual definition, making sure they never get out of sync. This also silences a sparse warning. Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/include/obd.h | 3 +++ drivers/staging/lustre/lustre/llite/vvp_internal.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 0f48e9c..1839f4f 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -43,6 +43,7 @@ #include "lustre_fld.h" #include "lustre_handles.h" #include "lustre_intent.h" +#include "cl_object.h" #define MAX_OBD_DEVICES 8192 @@ -76,6 +77,8 @@ static inline void loi_init(struct lov_oinfo *loi) struct lov_stripe_md; struct obd_info; +int lov_read_and_clear_async_rc(struct cl_object *clob); + typedef int (*obd_enqueue_update_f)(void *cookie, int rc); /* obd info for a particular level (lov, osc). */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h index c60d041..f40fd7f 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h @@ -301,8 +301,6 @@ static inline struct vvp_lock *cl2vvp_lock(const struct cl_lock_slice *slice) # define CLOBINVRNT(env, clob, expr) \ ((void)sizeof(env), (void)sizeof(clob), (void)sizeof(!!(expr))) -int lov_read_and_clear_async_rc(struct cl_object *clob); - int vvp_io_init(const struct lu_env *env, struct cl_object *obj, struct cl_io *io); int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io); -- 2.7.4 From jsimmons at infradead.org Wed Dec 7 22:49:12 2016 From: jsimmons at infradead.org (James Simmons) Date: Wed, 7 Dec 2016 17:49:12 -0500 Subject: [lustre-devel] [PATCH v2] staging: lustre: osc: handle osc eviction correctly Message-ID: <1481150952-16339-1-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong Cleanup everything if an OSC is being evicted. Group lock is not well supported yet. Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6271 Reviewed-on: http://review.whamcloud.com/14989 Reviewed-by: John L. Hammond Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- Changelog: v1) Initial patch v2) Remove ergo macro usage drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 3 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 25 ++++----- .../staging/lustre/lustre/osc/osc_cl_internal.h | 11 ++-- drivers/staging/lustre/lustre/osc/osc_internal.h | 2 + drivers/staging/lustre/lustre/osc/osc_io.c | 60 +++++++++++++++++----- drivers/staging/lustre/lustre/osc/osc_object.c | 19 +++++++ drivers/staging/lustre/lustre/osc/osc_request.c | 42 ++++++++++++--- 7 files changed, 124 insertions(+), 38 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index a4a291a..cdb5bd1 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1131,8 +1131,7 @@ static int lock_matches(struct ldlm_lock *lock, struct lock_match_data *data) if (!data->lmd_unref && LDLM_HAVE_MASK(lock, GONE)) return INTERVAL_ITER_CONT; - if ((data->lmd_flags & LDLM_FL_LOCAL_ONLY) && - !ldlm_is_local(lock)) + if (!equi(data->lmd_flags & LDLM_FL_LOCAL_ONLY, ldlm_is_local(lock))) return INTERVAL_ITER_CONT; if (data->lmd_flags & LDLM_FL_TEST_LOCK) { diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index b0f030c..a7f57f5 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -247,7 +247,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext, goto out; } - if (ext->oe_dlmlock) { + if (ext->oe_dlmlock && !ldlm_is_failed(ext->oe_dlmlock)) { struct ldlm_extent *extent; extent = &ext->oe_dlmlock->l_policy_data.l_extent; @@ -2710,8 +2710,8 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, /** * Called by osc_io_setattr_start() to freeze and destroy covering extents. */ -int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj, __u64 size) +int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, + u64 size, struct osc_extent **extp) { struct client_obd *cli = osc_cli(obj); struct osc_extent *ext; @@ -2808,9 +2808,11 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, /* we need to hold this extent in OES_TRUNC state so * that no writeback will happen. This is to avoid * BUG 17397. + * Only partial truncate can reach here, if @size is + * not zero, the caller should provide a valid @extp. */ - LASSERT(!oio->oi_trunc); - oio->oi_trunc = osc_extent_get(ext); + LASSERT(!*extp); + *extp = osc_extent_get(ext); OSC_EXTENT_DUMP(D_CACHE, ext, "trunc at %llu\n", size); } @@ -2836,13 +2838,10 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, /** * Called after osc_io_setattr_end to add oio->oi_trunc back to cache. */ -void osc_cache_truncate_end(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj) +void osc_cache_truncate_end(const struct lu_env *env, struct osc_extent *ext) { - struct osc_extent *ext = oio->oi_trunc; - - oio->oi_trunc = NULL; if (ext) { + struct osc_object *obj = ext->oe_obj; bool unplug = false; EASSERT(ext->oe_nr_pages > 0, ext); @@ -3183,8 +3182,10 @@ static int discard_cb(const struct lu_env *env, struct cl_io *io, /* page is top page. */ info->oti_next_index = osc_index(ops) + 1; if (cl_page_own(env, io, page) == 0) { - KLASSERT(ergo(page->cp_type == CPT_CACHEABLE, - !PageDirty(cl_page_vmpage(page)))); + if (page->cp_type == CPT_CACHEABLE && + PageDirty(cl_page_vmpage(page))) + CL_PAGE_DEBUG(D_ERROR, env, page, + "discard dirty page?\n"); /* discard the page */ cl_page_discard(env, io, page); diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index cce55a9..c09ab97d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -159,6 +159,10 @@ struct osc_object { /* Protect osc_lock this osc_object has */ spinlock_t oo_ol_spin; struct list_head oo_ol_list; + + /** number of active IOs of this object */ + atomic_t oo_nr_ios; + wait_queue_head_t oo_io_waitq; }; static inline void osc_object_lock(struct osc_object *obj) @@ -399,10 +403,9 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, 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); -int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj, __u64 size); -void osc_cache_truncate_end(const struct lu_env *env, struct osc_io *oio, - struct osc_object *obj); +int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, + u64 size, struct osc_extent **extp); +void osc_cache_truncate_end(const struct lu_env *env, struct osc_extent *ext); int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, pgoff_t start, pgoff_t end, int hp, int discard); int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 688783d..d9837b7 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -218,4 +218,6 @@ struct ldlm_lock *osc_dlmlock_at_pgoff(const struct lu_env *env, struct osc_object *obj, pgoff_t index, enum osc_dap_flags flags); +int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc); + #endif /* OSC_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 228a97c..d96f4f2 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -330,8 +330,25 @@ static int osc_io_commit_async(const struct lu_env *env, return result; } -static int osc_io_rw_iter_init(const struct lu_env *env, - const struct cl_io_slice *ios) +static int osc_io_iter_init(const struct lu_env *env, + const struct cl_io_slice *ios) +{ + struct osc_object *osc = cl2osc(ios->cis_obj); + struct obd_import *imp = osc_cli(osc)->cl_import; + int rc = -EIO; + + spin_lock(&imp->imp_lock); + if (likely(!imp->imp_invalid)) { + atomic_inc(&osc->oo_nr_ios); + rc = 0; + } + spin_unlock(&imp->imp_lock); + + return rc; +} + +static int osc_io_write_iter_init(const struct lu_env *env, + const struct cl_io_slice *ios) { struct cl_io *io = ios->cis_io; struct osc_io *oio = osc_env_io(env); @@ -342,7 +359,7 @@ static int osc_io_rw_iter_init(const struct lu_env *env, unsigned long max_pages; if (cl_io_is_append(io)) - return 0; + return osc_io_iter_init(env, ios); npages = io->u.ci_rw.crw_count >> PAGE_SHIFT; if (io->u.ci_rw.crw_pos & ~PAGE_MASK) @@ -374,11 +391,21 @@ static int osc_io_rw_iter_init(const struct lu_env *env, (void)ptlrpcd_queue_work(cli->cl_lru_work); } - return 0; + return osc_io_iter_init(env, ios); +} + +static void osc_io_iter_fini(const struct lu_env *env, + const struct cl_io_slice *ios) +{ + struct osc_object *osc = cl2osc(ios->cis_obj); + + LASSERT(atomic_read(&osc->oo_nr_ios) > 0); + if (atomic_dec_and_test(&osc->oo_nr_ios)) + wake_up_all(&osc->oo_io_waitq); } -static void osc_io_rw_iter_fini(const struct lu_env *env, - const struct cl_io_slice *ios) +static void osc_io_write_iter_fini(const struct lu_env *env, + const struct cl_io_slice *ios) { struct osc_io *oio = osc_env_io(env); struct osc_object *osc = cl2osc(ios->cis_obj); @@ -389,6 +416,8 @@ static void osc_io_rw_iter_fini(const struct lu_env *env, oio->oi_lru_reserved = 0; } oio->oi_write_osclock = NULL; + + osc_io_iter_fini(env, ios); } static int osc_io_fault_start(const struct lu_env *env, @@ -479,7 +508,8 @@ static int osc_io_setattr_start(const struct lu_env *env, /* truncate cache dirty pages first */ if (cl_io_is_trunc(io)) - result = osc_cache_truncate_start(env, oio, cl2osc(obj), size); + result = osc_cache_truncate_start(env, cl2osc(obj), size, + &oio->oi_trunc); if (result == 0 && oio->oi_lockless == 0) { cl_object_attr_lock(obj); @@ -589,10 +619,8 @@ static void osc_io_setattr_end(const struct lu_env *env, __u64 size = io->u.ci_setattr.sa_attr.lvb_size; osc_trunc_check(env, io, oio, size); - if (oio->oi_trunc) { - osc_cache_truncate_end(env, oio, cl2osc(obj)); - oio->oi_trunc = NULL; - } + osc_cache_truncate_end(env, oio->oi_trunc); + oio->oi_trunc = NULL; } } @@ -832,17 +860,21 @@ static void osc_io_end(const struct lu_env *env, static const struct cl_io_operations osc_io_ops = { .op = { [CIT_READ] = { + .cio_iter_init = osc_io_iter_init, + .cio_iter_fini = osc_io_iter_fini, .cio_start = osc_io_read_start, .cio_fini = osc_io_fini }, [CIT_WRITE] = { - .cio_iter_init = osc_io_rw_iter_init, - .cio_iter_fini = osc_io_rw_iter_fini, + .cio_iter_init = osc_io_write_iter_init, + .cio_iter_fini = osc_io_write_iter_fini, .cio_start = osc_io_write_start, .cio_end = osc_io_end, .cio_fini = osc_io_fini }, [CIT_SETATTR] = { + .cio_iter_init = osc_io_iter_init, + .cio_iter_fini = osc_io_iter_fini, .cio_start = osc_io_setattr_start, .cio_end = osc_io_setattr_end }, @@ -851,6 +883,8 @@ static void osc_io_end(const struct lu_env *env, .cio_end = osc_io_data_version_end, }, [CIT_FAULT] = { + .cio_iter_init = osc_io_iter_init, + .cio_iter_fini = osc_io_iter_fini, .cio_start = osc_io_fault_start, .cio_end = osc_io_end, .cio_fini = osc_io_fini diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index e0c3324..d3e5ca7 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -78,6 +78,9 @@ static int osc_object_init(const struct lu_env *env, struct lu_object *obj, INIT_LIST_HEAD(&osc->oo_write_item); INIT_LIST_HEAD(&osc->oo_read_item); + atomic_set(&osc->oo_nr_ios, 0); + init_waitqueue_head(&osc->oo_io_waitq); + osc->oo_root.rb_node = NULL; INIT_LIST_HEAD(&osc->oo_hp_exts); INIT_LIST_HEAD(&osc->oo_urgent_exts); @@ -112,6 +115,7 @@ static void osc_object_free(const struct lu_env *env, struct lu_object *obj) LASSERT(atomic_read(&osc->oo_nr_reads) == 0); LASSERT(atomic_read(&osc->oo_nr_writes) == 0); LASSERT(list_empty(&osc->oo_ol_list)); + LASSERT(!atomic_read(&osc->oo_nr_ios)); lu_object_fini(obj); kmem_cache_free(osc_object_kmem, osc); @@ -444,4 +448,19 @@ struct lu_object *osc_object_alloc(const struct lu_env *env, return obj; } +int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc) +{ + struct l_wait_info lwi = { 0 }; + + CDEBUG(D_INODE, "Invalidate osc object: %p, # of active IOs: %d\n", + osc, atomic_read(&osc->oo_nr_ios)); + + l_wait_event(osc->oo_io_waitq, !atomic_read(&osc->oo_nr_ios), &lwi); + + /* Discard all pages of this object. */ + osc_cache_truncate_start(env, osc, 0, NULL); + + return 0; +} + /** @} osc */ diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 7143564..757ddfa 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2479,6 +2479,33 @@ static int osc_disconnect(struct obd_export *exp) return rc; } +static int osc_ldlm_resource_invalidate(struct cfs_hash *hs, + struct cfs_hash_bd *bd, + struct hlist_node *hnode, void *arg) +{ + struct ldlm_resource *res = cfs_hash_object(hs, hnode); + struct osc_object *osc = NULL; + struct lu_env *env = arg; + struct ldlm_lock *lock; + + lock_res(res); + list_for_each_entry(lock, &res->lr_granted, l_res_link) { + if (lock->l_ast_data && !osc) { + osc = lock->l_ast_data; + cl_object_get(osc2cl(osc)); + } + lock->l_ast_data = NULL; + } + unlock_res(res); + + if (osc) { + osc_object_invalidate(env, osc); + cl_object_put(env, osc2cl(osc)); + } + + return 0; +} + static int osc_import_event(struct obd_device *obd, struct obd_import *imp, enum obd_import_event event) @@ -2506,17 +2533,18 @@ static int osc_import_event(struct obd_device *obd, struct lu_env *env; int refcheck; + ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); + env = cl_env_get(&refcheck); if (!IS_ERR(env)) { - /* Reset grants */ - cli = &obd->u.cli; - /* all pages go to failing rpcs due to the invalid - * import - */ - osc_io_unplug(env, cli, NULL); + osc_io_unplug(env, &obd->u.cli, NULL); - ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); + cfs_hash_for_each_nolock(ns->ns_rs_hash, + osc_ldlm_resource_invalidate, + env, 0); cl_env_put(env, &refcheck); + + ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); } else { rc = PTR_ERR(env); } -- 1.8.3.1 From jsimmons at infradead.org Wed Dec 7 22:55:17 2016 From: jsimmons at infradead.org (James Simmons) Date: Wed, 7 Dec 2016 17:55:17 -0500 Subject: [lustre-devel] [PATCH] staging: lustre: lnet: make brw_inject_one_error() static Message-ID: <1481151317-17688-1-git-send-email-jsimmons@infradead.org> It's not used anywhere outside of brw_test.c file. Highlighted by sparse. Signed-off-by: James Simmons --- drivers/staging/lustre/lnet/selftest/brw_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index 67b460f..b9ac34e 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -136,7 +136,7 @@ return 0; } -int brw_inject_one_error(void) +static int brw_inject_one_error(void) { struct timespec64 ts; -- 1.8.3.1 From jsimmons at infradead.org Wed Dec 7 23:16:44 2016 From: jsimmons at infradead.org (James Simmons) Date: Wed, 7 Dec 2016 23:16:44 +0000 (GMT) Subject: [lustre-devel] [PATCH 04/22] staging: lustre: osc: handle osc eviction correctly In-Reply-To: References: <1480726409-20350-1-git-send-email-jsimmons@infradead.org> <1480726409-20350-5-git-send-email-jsimmons@infradead.org> <20161205205537.GB31465@mwanda> Message-ID: > On Dec 5, 2016, at 3:55 PM, Dan Carpenter wrote: > > > On Fri, Dec 02, 2016 at 07:53:11PM -0500, James Simmons wrote: > >> @@ -3183,8 +3182,10 @@ static int discard_cb(const struct lu_env *env, struct cl_io *io, > >> /* page is top page. */ > >> info->oti_next_index = osc_index(ops) + 1; > >> if (cl_page_own(env, io, page) == 0) { > >> - KLASSERT(ergo(page->cp_type == CPT_CACHEABLE, > >> - !PageDirty(cl_page_vmpage(page)))); > >> + if (!ergo(page->cp_type == CPT_CACHEABLE, > >> + !PageDirty(cl_page_vmpage(page)))) > >> + CL_PAGE_DEBUG(D_ERROR, env, page, > >> + "discard dirty page?\n"); > > > > > > I don't understand the point of the ergo macro. There are way too many > > double negatives (some of them hidden for my small brain). How is that > > simpler than just writing it out: > > > > if (page->cp_type == CPT_CACHEABLE && > > PageDirty(cl_page_vmpage(page)) > > CL_PAGE_DEBUG(D_ERROR, env, page, "discard dirty page?\n"); > > I guess it makes it sound chic or something? > I am not a huge fan of it either, esp. in a case like this, though > it might be somewhat more convenient in assertions (where this is converted from). Not a fan either. Resubmitted patch with ergo removed. From viro at ZenIV.linux.org.uk Wed Dec 7 23:46:39 2016 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Wed, 7 Dec 2016 23:46:39 +0000 Subject: [lustre-devel] [PATCH 0/8] Sparse warning fixes in Lustre. In-Reply-To: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> Message-ID: <20161207234639.GU1555@ZenIV.linux.org.uk> On Wed, Dec 07, 2016 at 05:41:26PM -0500, Oleg Drokin wrote: > This set of fixes aims at sparse warnings. Speaking of the stuff sparse catches there: class_process_proc_param(). I've tried to describe what I think of that Fine Piece Of Software several times, but I had to give up - my command of obscenity is not up to the task, neither in English nor in Russian. Please, take it out. Preferably - along with the ->ldo_process_config()/->process_config() thing. From jsimmons at infradead.org Thu Dec 8 00:16:28 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:16:28 +0000 (GMT) Subject: [lustre-devel] [PATCH 2/8] staging/lustre/ldlm: Correct itree_overlap_cb return type In-Reply-To: <1481150494-1853127-3-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-3-git-send-email-green@linuxhacker.ru> Message-ID: > As per interval_search() prototype, the callback should return > enum, not int. > This fixes correspondign sparse warning. > > Signed-off-by: Oleg Drokin Reviewed-by: James Simmons > --- > drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > index a4a291a..f4cbc89 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > @@ -1148,7 +1148,7 @@ static int lock_matches(struct ldlm_lock *lock, struct lock_match_data *data) > return INTERVAL_ITER_STOP; > } > > -static unsigned int itree_overlap_cb(struct interval_node *in, void *args) > +static enum interval_iter itree_overlap_cb(struct interval_node *in, void *args) > { > struct ldlm_interval *node = to_ldlm_interval(in); > struct lock_match_data *data = args; > -- > 2.7.4 > > From jsimmons at infradead.org Thu Dec 8 00:21:19 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:21:19 +0000 (GMT) Subject: [lustre-devel] [PATCH 2/8] staging/lustre/ldlm: Correct itree_overlap_cb return type In-Reply-To: <1481150494-1853127-3-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-3-git-send-email-green@linuxhacker.ru> Message-ID: > As per interval_search() prototype, the callback should return > enum, not int. > This fixes correspondign sparse warning. > > Signed-off-by: Oleg Drokin Reviewed-by: James Simmons > --- > drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > index a4a291a..f4cbc89 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c > @@ -1148,7 +1148,7 @@ static int lock_matches(struct ldlm_lock *lock, struct lock_match_data *data) > return INTERVAL_ITER_STOP; > } > > -static unsigned int itree_overlap_cb(struct interval_node *in, void *args) > +static enum interval_iter itree_overlap_cb(struct interval_node *in, void *args) > { > struct ldlm_interval *node = to_ldlm_interval(in); > struct lock_match_data *data = args; > -- > 2.7.4 > > From jsimmons at infradead.org Thu Dec 8 00:22:02 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:22:02 +0000 (GMT) Subject: [lustre-devel] [PATCH 5/8] staging/lustre/osc: extern declare osc_caches in a header In-Reply-To: <1481150494-1853127-6-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-6-git-send-email-green@linuxhacker.ru> Message-ID: > This avoids frowned upon extern in the C file, and also > shuts down a sparse warning of > drivers/staging/lustre/lustre/osc/osc_dev.c:55:22: warning: symbol 'osc_caches' was not declared. Should it be static? Reviewed-by: James Simmons > Signed-off-by: Oleg Drokin > --- > drivers/staging/lustre/lustre/osc/osc_internal.h | 2 ++ > drivers/staging/lustre/lustre/osc/osc_request.c | 2 -- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h > index 688783d..5cce82b 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_internal.h > +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h > @@ -181,6 +181,8 @@ static inline struct osc_device *obd2osc_dev(const struct obd_device *d) > return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev); > } > > +extern struct lu_kmem_descr osc_caches[]; > + > extern struct kmem_cache *osc_quota_kmem; > struct osc_quota_info { > /** linkage for quota hash table */ > diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c > index 7143564..f691297 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_request.c > +++ b/drivers/staging/lustre/lustre/osc/osc_request.c > @@ -2766,8 +2766,6 @@ static struct obd_ops osc_obd_ops = { > .quotactl = osc_quotactl, > }; > > -extern struct lu_kmem_descr osc_caches[]; > - > static int __init osc_init(void) > { > struct lprocfs_static_vars lvars = { NULL }; > -- > 2.7.4 > > From jsimmons at infradead.org Thu Dec 8 00:23:18 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:23:18 +0000 (GMT) Subject: [lustre-devel] [PATCH 5/8] staging/lustre/osc: extern declare osc_caches in a header In-Reply-To: <1481150494-1853127-6-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-6-git-send-email-green@linuxhacker.ru> Message-ID: > This avoids frowned upon extern in the C file, and also > shuts down a sparse warning of > drivers/staging/lustre/lustre/osc/osc_dev.c:55:22: warning: symbol 'osc_caches' was not declared. Should it be static? Reviewed-by: James Simmons > Signed-off-by: Oleg Drokin > --- > drivers/staging/lustre/lustre/osc/osc_internal.h | 2 ++ > drivers/staging/lustre/lustre/osc/osc_request.c | 2 -- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h > index 688783d..5cce82b 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_internal.h > +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h > @@ -181,6 +181,8 @@ static inline struct osc_device *obd2osc_dev(const struct obd_device *d) > return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev); > } > > +extern struct lu_kmem_descr osc_caches[]; > + > extern struct kmem_cache *osc_quota_kmem; > struct osc_quota_info { > /** linkage for quota hash table */ > diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c > index 7143564..f691297 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_request.c > +++ b/drivers/staging/lustre/lustre/osc/osc_request.c > @@ -2766,8 +2766,6 @@ static struct obd_ops osc_obd_ops = { > .quotactl = osc_quotactl, > }; > > -extern struct lu_kmem_descr osc_caches[]; > - > static int __init osc_init(void) > { > struct lprocfs_static_vars lvars = { NULL }; > -- > 2.7.4 > > From jsimmons at infradead.org Thu Dec 8 00:23:57 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:23:57 +0000 (GMT) Subject: [lustre-devel] [PATCH 4/8] staging/lustre/lov: make lov_lsm_alloc() static In-Reply-To: <1481150494-1853127-5-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-5-git-send-email-green@linuxhacker.ru> Message-ID: > It's not used anywhere outside of this file. > Highlighted by sparse. Reviewed-by: James Simmons > Signed-off-by: Oleg Drokin > --- > drivers/staging/lustre/lustre/lov/lov_pack.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c > index 6c93d18..68fa2de 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_pack.c > +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c > @@ -198,7 +198,8 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count) > return rc; > } > > -struct lov_stripe_md *lov_lsm_alloc(u16 stripe_count, u32 pattern, u32 magic) > +static struct lov_stripe_md *lov_lsm_alloc(u16 stripe_count, u32 pattern, > + u32 magic) > { > struct lov_stripe_md *lsm; > unsigned int i; > -- > 2.7.4 > > From jsimmons at infradead.org Thu Dec 8 00:24:17 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:24:17 +0000 (GMT) Subject: [lustre-devel] [PATCH 3/8] staging/lustre/llite: mark ll_io_init() static In-Reply-To: <1481150494-1853127-4-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-4-git-send-email-green@linuxhacker.ru> Message-ID: > It's not used anywhere out of this file. > Highlighted by sparse. Reviewed-by: James Simmons > Signed-off-by: Oleg Drokin > --- > drivers/staging/lustre/lustre/llite/file.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c > index f634c11..d93f06a 100644 > --- a/drivers/staging/lustre/lustre/llite/file.c > +++ b/drivers/staging/lustre/lustre/llite/file.c > @@ -1016,7 +1016,7 @@ static bool file_is_noatime(const struct file *file) > return false; > } > > -void ll_io_init(struct cl_io *io, const struct file *file, int write) > +static void ll_io_init(struct cl_io *io, const struct file *file, int write) > { > struct inode *inode = file_inode(file); > > -- > 2.7.4 > > From jsimmons at infradead.org Thu Dec 8 00:24:42 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:24:42 +0000 (GMT) Subject: [lustre-devel] [PATCH 7/8] staging/lustre: Move lov_read_and_clear_async_rc declaration In-Reply-To: <1481150494-1853127-8-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-8-git-send-email-green@linuxhacker.ru> Message-ID: > Move it to obd.h, so that it's included from both the users and > the actual definition, making sure they never get out of sync. > This also silences a sparse warning. Reviewed-by: James Simmons > Signed-off-by: Oleg Drokin > --- > drivers/staging/lustre/lustre/include/obd.h | 3 +++ > drivers/staging/lustre/lustre/llite/vvp_internal.h | 2 -- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h > index 0f48e9c..1839f4f 100644 > --- a/drivers/staging/lustre/lustre/include/obd.h > +++ b/drivers/staging/lustre/lustre/include/obd.h > @@ -43,6 +43,7 @@ > #include "lustre_fld.h" > #include "lustre_handles.h" > #include "lustre_intent.h" > +#include "cl_object.h" > > #define MAX_OBD_DEVICES 8192 > > @@ -76,6 +77,8 @@ static inline void loi_init(struct lov_oinfo *loi) > struct lov_stripe_md; > struct obd_info; > > +int lov_read_and_clear_async_rc(struct cl_object *clob); > + > typedef int (*obd_enqueue_update_f)(void *cookie, int rc); > > /* obd info for a particular level (lov, osc). */ > diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h > index c60d041..f40fd7f 100644 > --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h > +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h > @@ -301,8 +301,6 @@ static inline struct vvp_lock *cl2vvp_lock(const struct cl_lock_slice *slice) > # define CLOBINVRNT(env, clob, expr) \ > ((void)sizeof(env), (void)sizeof(clob), (void)sizeof(!!(expr))) > > -int lov_read_and_clear_async_rc(struct cl_object *clob); > - > int vvp_io_init(const struct lu_env *env, struct cl_object *obj, > struct cl_io *io); > int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io); > -- > 2.7.4 > > From jsimmons at infradead.org Thu Dec 8 00:25:11 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:25:11 +0000 (GMT) Subject: [lustre-devel] [PATCH 8/8] staging/lustre/ptlrpc: Move nrs_conf_fifo extern to a header In-Reply-To: <1481150494-1853127-9-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-9-git-send-email-green@linuxhacker.ru> Message-ID: > This avoids having an extern definition in a C file which is bad, > and also silences sparse complaint as well. > > Signed-off-by: Oleg Drokin Reviewed-by: James Simmons > --- > drivers/staging/lustre/lustre/ptlrpc/nrs.c | 3 --- > drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 3 +++ > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c > index 7b6ffb1..ef19dbe 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c > @@ -1559,9 +1559,6 @@ int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc, > return rc; > } > > -/* ptlrpc/nrs_fifo.c */ > -extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; > - > /** > * Adds all policies that ship with the ptlrpc module, to NRS core's list of > * policies \e nrs_core.nrs_policies. > diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h > index e0f859c..8e6a805 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h > +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h > @@ -226,6 +226,9 @@ struct ptlrpc_nrs_policy *nrs_request_policy(struct ptlrpc_nrs_request *nrq) > sizeof(NRS_LPROCFS_QUANTUM_NAME_REG __stringify(LPROCFS_NRS_QUANTUM_MAX) " " \ > NRS_LPROCFS_QUANTUM_NAME_HP __stringify(LPROCFS_NRS_QUANTUM_MAX)) > > +/* ptlrpc/nrs_fifo.c */ > +extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; > + > /* recovd_thread.c */ > > int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink); > -- > 2.7.4 > > From jsimmons at infradead.org Thu Dec 8 00:27:27 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:27:27 +0000 (GMT) Subject: [lustre-devel] [PATCH 8/8] staging/lustre/ptlrpc: Move nrs_conf_fifo extern to a header In-Reply-To: <1481150494-1853127-9-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-9-git-send-email-green@linuxhacker.ru> Message-ID: > This avoids having an extern definition in a C file which is bad, > and also silences sparse complaint as well. > > Signed-off-by: Oleg Drokin Reviewed-by: James Simmons > --- > drivers/staging/lustre/lustre/ptlrpc/nrs.c | 3 --- > drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 3 +++ > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c > index 7b6ffb1..ef19dbe 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c > @@ -1559,9 +1559,6 @@ int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc, > return rc; > } > > -/* ptlrpc/nrs_fifo.c */ > -extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; > - > /** > * Adds all policies that ship with the ptlrpc module, to NRS core's list of > * policies \e nrs_core.nrs_policies. > diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h > index e0f859c..8e6a805 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h > +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h > @@ -226,6 +226,9 @@ struct ptlrpc_nrs_policy *nrs_request_policy(struct ptlrpc_nrs_request *nrq) > sizeof(NRS_LPROCFS_QUANTUM_NAME_REG __stringify(LPROCFS_NRS_QUANTUM_MAX) " " \ > NRS_LPROCFS_QUANTUM_NAME_HP __stringify(LPROCFS_NRS_QUANTUM_MAX)) > > +/* ptlrpc/nrs_fifo.c */ > +extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; > + > /* recovd_thread.c */ > > int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink); > -- > 2.7.4 > > From jsimmons at infradead.org Thu Dec 8 00:28:28 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:28:28 +0000 (GMT) Subject: [lustre-devel] [PATCH 6/8] staging/lustre: Declare lu_context/session_tags_default In-Reply-To: <1481150494-1853127-7-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-7-git-send-email-green@linuxhacker.ru> Message-ID: > Make the declaration in a header, not as an extern in a C file, > that is frowned upon. > This also makes sparse a little bit more happy. > Reviewed-by: James Simmons > Signed-off-by: Oleg Drokin > --- > drivers/staging/lustre/lustre/include/lu_object.h | 3 +++ > drivers/staging/lustre/lustre/obdclass/cl_object.c | 3 +-- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h > index 260643e..69b2812 100644 > --- a/drivers/staging/lustre/lustre/include/lu_object.h > +++ b/drivers/staging/lustre/lustre/include/lu_object.h > @@ -1326,5 +1326,8 @@ void lu_buf_realloc(struct lu_buf *buf, size_t size); > int lu_buf_check_and_grow(struct lu_buf *buf, size_t len); > struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, size_t len); > > +extern __u32 lu_context_tags_default; > +extern __u32 lu_session_tags_default; > + > /** @} lu */ > #endif /* __LUSTRE_LU_OBJECT_H */ > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c > index f5d4e23..703cb67 100644 > --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c > +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c > @@ -54,6 +54,7 @@ > #include > #include "../../include/linux/libcfs/libcfs_hash.h" /* for cfs_hash stuff */ > #include "../include/cl_object.h" > +#include "../include/lu_object.h" > #include "cl_internal.h" > > static struct kmem_cache *cl_env_kmem; > @@ -61,8 +62,6 @@ static struct kmem_cache *cl_env_kmem; > /** Lock class of cl_object_header::coh_attr_guard */ > static struct lock_class_key cl_attr_guard_class; > > -extern __u32 lu_context_tags_default; > -extern __u32 lu_session_tags_default; > /** > * Initialize cl_object_header. > */ > -- > 2.7.4 > > From jsimmons at infradead.org Thu Dec 8 00:44:38 2016 From: jsimmons at infradead.org (James Simmons) Date: Thu, 8 Dec 2016 00:44:38 +0000 (GMT) Subject: [lustre-devel] [PATCH 1/8] staging/lustre/llite: move root_squash from sysfs to debugfs In-Reply-To: <1481150494-1853127-2-git-send-email-green@linuxhacker.ru> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <1481150494-1853127-2-git-send-email-green@linuxhacker.ru> Message-ID: > root_squash control got accidentally moved to sysfs instead of > debugfs, and the write side of it was also broken expecting a > userspace buffer. > It contains both uid and gid values in a single file, so debugfs > is a clear place for it. I see why this was missed. The uid/gid pair I needed for my testing was missing so the test was skipped. I fixed it up and tested this patch out. Now it passes. Reviewed-by: James Simmons > Reported-by: Al Viro > Fixes: c948390f10ccc "fix inconsistencies of root squash feature" > Signed-off-by: Oleg Drokin > --- > drivers/staging/lustre/lustre/llite/lproc_llite.c | 27 +++++++++++++---------- > 1 file changed, 15 insertions(+), 12 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c > index 03682c1..f3ee584 100644 > --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c > +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c > @@ -924,27 +924,29 @@ static ssize_t ll_unstable_stats_seq_write(struct file *file, > } > LPROC_SEQ_FOPS(ll_unstable_stats); > > -static ssize_t root_squash_show(struct kobject *kobj, struct attribute *attr, > - char *buf) > +static int ll_root_squash_seq_show(struct seq_file *m, void *v) > { > - struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, > - ll_kobj); > + struct super_block *sb = m->private; > + struct ll_sb_info *sbi = ll_s2sbi(sb); > struct root_squash_info *squash = &sbi->ll_squash; > > - return sprintf(buf, "%u:%u\n", squash->rsi_uid, squash->rsi_gid); > + seq_printf(m, "%u:%u\n", squash->rsi_uid, squash->rsi_gid); > + return 0; > } > > -static ssize_t root_squash_store(struct kobject *kobj, struct attribute *attr, > - const char *buffer, size_t count) > +static ssize_t ll_root_squash_seq_write(struct file *file, > + const char __user *buffer, > + size_t count, loff_t *off) > { > - struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, > - ll_kobj); > + struct seq_file *m = file->private_data; > + struct super_block *sb = m->private; > + struct ll_sb_info *sbi = ll_s2sbi(sb); > struct root_squash_info *squash = &sbi->ll_squash; > > return lprocfs_wr_root_squash(buffer, count, squash, > - ll_get_fsname(sbi->ll_sb, NULL, 0)); > + ll_get_fsname(sb, NULL, 0)); > } > -LUSTRE_RW_ATTR(root_squash); > +LPROC_SEQ_FOPS(ll_root_squash); > > static int ll_nosquash_nids_seq_show(struct seq_file *m, void *v) > { > @@ -997,6 +999,8 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { > { "statahead_stats", &ll_statahead_stats_fops, NULL, 0 }, > { "unstable_stats", &ll_unstable_stats_fops, NULL }, > { "sbi_flags", &ll_sbi_flags_fops, NULL, 0 }, > + { .name = "root_squash", > + .fops = &ll_root_squash_fops }, > { .name = "nosquash_nids", > .fops = &ll_nosquash_nids_fops }, > { NULL } > @@ -1027,7 +1031,6 @@ static struct attribute *llite_attrs[] = { > &lustre_attr_max_easize.attr, > &lustre_attr_default_easize.attr, > &lustre_attr_xattr_cache.attr, > - &lustre_attr_root_squash.attr, > NULL, > }; > > -- > 2.7.4 > > From peter.a.jones at intel.com Thu Dec 8 04:25:57 2016 From: peter.a.jones at intel.com (Jones, Peter A) Date: Thu, 8 Dec 2016 04:25:57 +0000 Subject: [lustre-devel] Lustre 2.9.0 released Message-ID: We are pleased to announce that the Lustre 2.9.0 Release has been declared GA and is available for download . You can also grab the source from git This major release includes new features: UID/GID Mapping Provides the capability to remap user and group IDs based on node address so as to simplify administration when sharing access between security domains (LU-3291) Shared Key Crypto Identifies clients/servers and authenticates/encrypts RPCs (LU-3289) Subdirectory Mounts Offers the option for clients to be able to mount only a defined subset of the filesystem (LU-29) Server Side Advise and Hinting A Lustre equivalent of fadvise that provides hints to the server about the nature of the data access (willread, dontreed) so that appropriate steps can be taken. (LU-4931) Large Bulk IO Allows the configuration of larger options to be able to get more efficient network/disk IO . (LU-7990) Weak Updates Lustre support for weak updates (KMP) has been added. Please note the associated name changes for the RPMs . (LU-5614) Fuller details can be found in the 2.9 wiki page (including the change log and test matrix) The following are known issues in the Lustre 2.9 Release: LU-8313 – Deployments using kerberos that have upgraded from an earlier release will need to manually add a–k flag to svcgssd in order to maintain compatibility LU-8880 – Kerberos does not behave in a consistent manner when deploying in a DNE configuration These issues are being actively worked and have proposed fixes under testing and review. Please log any issues found in the issue tracking system Thanks to all those who have contributed to the creation of this release. -------------- next part -------------- An HTML attachment was scrubbed... URL: From oleg.drokin at intel.com Thu Dec 8 05:43:15 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Thu, 8 Dec 2016 00:43:15 -0500 Subject: [lustre-devel] New tag 2.9.50 Message-ID: Hello! I have just tagged 2.9.50 in the lustre master development branch which opens up the floodgates for Lustre 2.10 development, since 2.9.0 development has just concluded. 2.9.50 tag is identical to 2.9.0 release at this point so there's no changelog to attach yet. Bye, Oleg From lambert.quentin at gmail.com Thu Dec 8 16:07:59 2016 From: lambert.quentin at gmail.com (Quentin Lambert) Date: Thu, 8 Dec 2016 17:07:59 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: Fix variable type declaration after refactoring Message-ID: <20161208160759.19649-1-lambert.quentin@gmail.com> A recent clean-up declared och_flags as a int rather than fmode_t. This lead to the following sparse warning: drivers/staging/lustre/lustre/llite/file.c:106:30: warning: restricted fmode_t degrades to integer This patch fixes this issue. Fixes: 1200991234f7 ("staging: lustre: cleanup lustre_lib.h") Signed-off-by: Quentin Lambert --- drivers/staging/lustre/lustre/include/obd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -889,7 +889,7 @@ struct obd_client_handle { struct md_open_data *och_mod; struct lustre_handle och_lease_handle; /* open lock for lease */ __u32 och_magic; - int och_flags; + fmode_t och_flags; }; #define OBD_CLIENT_HANDLE_MAGIC 0xd15ea5ed From dan.carpenter at oracle.com Thu Dec 8 19:36:21 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Thu, 8 Dec 2016 22:36:21 +0300 Subject: [lustre-devel] [PATCH] staging: lustre: Fix variable type declaration after refactoring In-Reply-To: <20161208160759.19649-1-lambert.quentin@gmail.com> References: <20161208160759.19649-1-lambert.quentin@gmail.com> Message-ID: <20161208193620.GX8176@mwanda> On Thu, Dec 08, 2016 at 05:07:59PM +0100, Quentin Lambert wrote: > A recent clean-up declared och_flags as a int rather than fmode_t. This > lead to the following sparse warning: > > drivers/staging/lustre/lustre/llite/file.c:106:30: warning: restricted > fmode_t degrades to integer > > This patch fixes this issue. > > Fixes: 1200991234f7 ("staging: lustre: cleanup lustre_lib.h") 0a1200991234f7 Fixes hash is wrong. It should start with "0a". regards, dan carpenter From lambert.quentin at gmail.com Thu Dec 8 20:38:27 2016 From: lambert.quentin at gmail.com (Quentin Lambert) Date: Thu, 8 Dec 2016 21:38:27 +0100 Subject: [lustre-devel] [PATCH v2] staging: lustre: Fix variable type declaration after refactoring In-Reply-To: <20161208160759.19649-1-lambert.quentin@gmail.com> Message-ID: <20161208203827.20561-1-lambert.quentin@gmail.com> A recent clean-up declared och_flags as a int rather than fmode_t. This lead to the following sparse warning: drivers/staging/lustre/lustre/llite/file.c:106:30: warning: restricted fmode_t degrades to integer This patch fixes this issue. Fixes: 0a1200991234f7 ("staging: lustre: cleanup lustre_lib.h") Signed-off-by: Quentin Lambert --- v2: fixes the referenced sha drivers/staging/lustre/lustre/include/obd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -889,7 +889,7 @@ struct obd_client_handle { struct md_open_data *och_mod; struct lustre_handle och_lease_handle; /* open lock for lease */ __u32 och_magic; - int och_flags; + fmode_t och_flags; }; #define OBD_CLIENT_HANDLE_MAGIC 0xd15ea5ed From jsimmons at infradead.org Sat Dec 10 18:05:56 2016 From: jsimmons at infradead.org (James Simmons) Date: Sat, 10 Dec 2016 13:05:56 -0500 Subject: [lustre-devel] [PATCH v2 0/5] Fix ups to make lustre_idl.h a proper UAPI header Message-ID: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> From: James Simmons James Simmons Fix ups to make lustre_idl.h a proper UAPI header The header lustre_idl.h is a UAPI header which contains extras that don't belong. This patch set moves a bunch of very kernel specific material out of the header. Lastly proper byteorder functions are used so this file can build in user space as well. Ben Evans (4): staging: lustre: obdclass: Create a header for obdo related functions staging: lustre: obdclass: style cleanup for obdo related functions staging: lustre: headers: sort headers affected by obdo move staging: lustre: headers: Move functions out of lustre_idl.h James Simmons (1): staging: lustre: headers: use proper byteorder functions in lustre_idl.h .../lustre/lustre/include/lustre/lustre_idl.h | 174 ++++----------------- drivers/staging/lustre/lustre/include/lustre_dlm.h | 13 ++ .../staging/lustre/lustre/include/lustre_obdo.h | 54 +++++++ .../staging/lustre/lustre/include/lustre_swab.h | 6 + drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 6 + drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 27 ++++ drivers/staging/lustre/lustre/mdc/mdc_lib.c | 6 + drivers/staging/lustre/lustre/obdclass/obdo.c | 54 +++++++ drivers/staging/lustre/lustre/osc/osc_io.c | 2 + drivers/staging/lustre/lustre/osc/osc_request.c | 16 +- 10 files changed, 206 insertions(+), 152 deletions(-) create mode 100644 drivers/staging/lustre/lustre/include/lustre_obdo.h -- 1.8.3.1 From jsimmons at infradead.org Sat Dec 10 18:05:58 2016 From: jsimmons at infradead.org (James Simmons) Date: Sat, 10 Dec 2016 13:05:58 -0500 Subject: [lustre-devel] [PATCH v2 2/5] staging: lustre: obdclass: style cleanup for obdo related functions In-Reply-To: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> Message-ID: <1481393161-22623-3-git-send-email-jsimmons@infradead.org> From: Ben Evans Change the style of lustre_get_wire_obdo and lustre_set_wire_obdo to conform to linux kernel standard. Signed-off-by: Ben Evans Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6401 Reviewed-on: http://review.whamcloud.com/16917 Reviewed-on: http://review.whamcloud.com/19266 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/obdo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index 241e60b..b1dfa16 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -139,7 +139,8 @@ void lustre_set_wire_obdo(const struct obd_connect_data *ocd, if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && fid_seq_is_echo(ostid_seq(&lobdo->o_oi))) { - /* Currently OBD_FL_OSTID will only be used when 2.4 echo + /* + * Currently OBD_FL_OSTID will only be used when 2.4 echo * client communicate with pre-2.4 server */ wobdo->o_oi.oi.oi_id = fid_oid(&lobdo->o_oi.oi_fid); @@ -154,13 +155,13 @@ void lustre_set_wire_obdo(const struct obd_connect_data *ocd, void lustre_get_wire_obdo(const struct obd_connect_data *ocd, struct obdo *lobdo, const struct obdo *wobdo) { - __u32 local_flags = 0; + u32 local_flags = 0; if (lobdo->o_valid & OBD_MD_FLFLAGS) local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; *lobdo = *wobdo; - if (local_flags != 0) { + if (local_flags) { lobdo->o_valid |= OBD_MD_FLFLAGS; lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; lobdo->o_flags |= local_flags; -- 1.8.3.1 From jsimmons at infradead.org Sat Dec 10 18:06:01 2016 From: jsimmons at infradead.org (James Simmons) Date: Sat, 10 Dec 2016 13:06:01 -0500 Subject: [lustre-devel] [PATCH v2 5/5] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> Message-ID: <1481393161-22623-6-git-send-email-jsimmons@infradead.org> In order for lustre_idl.h to be usable for both user land and kernel space it has to use the proper byteorder functions. Signed-off-by: James Simmons Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245 Reviewed-on: http://review.whamcloud.com/16916 Reviewed-by: Frank Zago Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Reviewed-by: John L. Hammond Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_idl.h | 55 ++++++++++++---------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index cd2dbfb..3d74d56 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -69,6 +69,9 @@ #ifndef _LUSTRE_IDL_H_ #define _LUSTRE_IDL_H_ +#include +#include + #include "../../../include/linux/libcfs/libcfs.h" #include "../../../include/linux/lnet/types.h" @@ -687,30 +690,30 @@ static inline void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen) */ static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src) { - dst->f_seq = cpu_to_le64(fid_seq(src)); - dst->f_oid = cpu_to_le32(fid_oid(src)); - dst->f_ver = cpu_to_le32(fid_ver(src)); + dst->f_seq = __cpu_to_le64(fid_seq(src)); + dst->f_oid = __cpu_to_le32(fid_oid(src)); + dst->f_ver = __cpu_to_le32(fid_ver(src)); } static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src) { - dst->f_seq = le64_to_cpu(fid_seq(src)); - dst->f_oid = le32_to_cpu(fid_oid(src)); - dst->f_ver = le32_to_cpu(fid_ver(src)); + dst->f_seq = __le64_to_cpu(fid_seq(src)); + dst->f_oid = __le32_to_cpu(fid_oid(src)); + dst->f_ver = __le32_to_cpu(fid_ver(src)); } static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src) { - dst->f_seq = cpu_to_be64(fid_seq(src)); - dst->f_oid = cpu_to_be32(fid_oid(src)); - dst->f_ver = cpu_to_be32(fid_ver(src)); + dst->f_seq = __cpu_to_be64(fid_seq(src)); + dst->f_oid = __cpu_to_be32(fid_oid(src)); + dst->f_ver = __cpu_to_be32(fid_ver(src)); } static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src) { - dst->f_seq = be64_to_cpu(fid_seq(src)); - dst->f_oid = be32_to_cpu(fid_oid(src)); - dst->f_ver = be32_to_cpu(fid_ver(src)); + dst->f_seq = __be64_to_cpu(fid_seq(src)); + dst->f_oid = __be32_to_cpu(fid_oid(src)); + dst->f_ver = __be32_to_cpu(fid_ver(src)); } static inline bool fid_is_sane(const struct lu_fid *fid) @@ -747,8 +750,8 @@ static inline void ostid_cpu_to_le(const struct ost_id *src_oi, struct ost_id *dst_oi) { if (fid_seq_is_mdt0(ostid_seq(src_oi))) { - dst_oi->oi.oi_id = cpu_to_le64(src_oi->oi.oi_id); - dst_oi->oi.oi_seq = cpu_to_le64(src_oi->oi.oi_seq); + dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq); } else { fid_cpu_to_le(&dst_oi->oi_fid, &src_oi->oi_fid); } @@ -758,8 +761,8 @@ static inline void ostid_le_to_cpu(const struct ost_id *src_oi, struct ost_id *dst_oi) { if (fid_seq_is_mdt0(ostid_seq(src_oi))) { - dst_oi->oi.oi_id = le64_to_cpu(src_oi->oi.oi_id); - dst_oi->oi.oi_seq = le64_to_cpu(src_oi->oi.oi_seq); + dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq); } else { fid_le_to_cpu(&dst_oi->oi_fid, &src_oi->oi_fid); } @@ -866,7 +869,7 @@ enum lu_dirpage_flags { static inline struct lu_dirent *lu_dirent_start(struct lu_dirpage *dp) { - if (le32_to_cpu(dp->ldp_flags) & LDF_EMPTY) + if (__le32_to_cpu(dp->ldp_flags) & LDF_EMPTY) return NULL; else return dp->ldp_entries; @@ -876,8 +879,8 @@ static inline struct lu_dirent *lu_dirent_next(struct lu_dirent *ent) { struct lu_dirent *next; - if (le16_to_cpu(ent->lde_reclen) != 0) - next = ((void *)ent) + le16_to_cpu(ent->lde_reclen); + if (__le16_to_cpu(ent->lde_reclen) != 0) + next = ((void *)ent) + __le16_to_cpu(ent->lde_reclen); else next = NULL; @@ -1438,15 +1441,15 @@ static inline __u64 lmm_oi_seq(const struct ost_id *oi) static inline void lmm_oi_le_to_cpu(struct ost_id *dst_oi, const struct ost_id *src_oi) { - dst_oi->oi.oi_id = le64_to_cpu(src_oi->oi.oi_id); - dst_oi->oi.oi_seq = le64_to_cpu(src_oi->oi.oi_seq); + dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq); } static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi, const struct ost_id *src_oi) { - dst_oi->oi.oi_id = cpu_to_le64(src_oi->oi.oi_id); - dst_oi->oi.oi_seq = cpu_to_le64(src_oi->oi.oi_seq); + dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq); } #define MAX_MD_SIZE \ @@ -2382,11 +2385,11 @@ static inline ssize_t lmv_mds_md_size(int stripe_count, unsigned int lmm_magic) static inline int lmv_mds_md_stripe_count_get(const union lmv_mds_md *lmm) { - switch (le32_to_cpu(lmm->lmv_magic)) { + switch (__le32_to_cpu(lmm->lmv_magic)) { case LMV_MAGIC_V1: - return le32_to_cpu(lmm->lmv_md_v1.lmv_stripe_count); + return __le32_to_cpu(lmm->lmv_md_v1.lmv_stripe_count); case LMV_USER_MAGIC: - return le32_to_cpu(lmm->lmv_user_md.lum_stripe_count); + return __le32_to_cpu(lmm->lmv_user_md.lum_stripe_count); default: return -EINVAL; } -- 1.8.3.1 From jsimmons at infradead.org Sat Dec 10 18:06:00 2016 From: jsimmons at infradead.org (James Simmons) Date: Sat, 10 Dec 2016 13:06:00 -0500 Subject: [lustre-devel] [PATCH v2 4/5] staging: lustre: headers: Move functions out of lustre_idl.h In-Reply-To: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> Message-ID: <1481393161-22623-5-git-send-email-jsimmons@infradead.org> From: Ben Evans Migrate functions set/get_mrc_cr_flags, ldlm_res_eq ldlm_extent_overlap, ldlm_extent_contain, ldlm_request_bufsize, and alll the PTLRPC dump_* functions out of lustre_idl.h which is a UAPI header to the places in the kernel code they are actually used. Delete unused lmv_mds_md_stripe_count and agent_req_in_final_state. Signed-off-by: Ben Evans Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6401 Reviewed-on: http://review.whamcloud.com/21484 Reviewed-by: Frank Zago Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_idl.h | 73 ---------------------- drivers/staging/lustre/lustre/include/lustre_dlm.h | 13 ++++ .../staging/lustre/lustre/include/lustre_swab.h | 6 ++ drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 6 ++ drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 27 ++++++++ drivers/staging/lustre/lustre/mdc/mdc_lib.c | 6 ++ 6 files changed, 58 insertions(+), 73 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index b0eb80d..cd2dbfb 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -2130,17 +2130,6 @@ struct mdt_rec_create { __u32 cr_padding_4; /* rr_padding_4 */ }; -static inline void set_mrc_cr_flags(struct mdt_rec_create *mrc, __u64 flags) -{ - mrc->cr_flags_l = (__u32)(flags & 0xFFFFFFFFUll); - mrc->cr_flags_h = (__u32)(flags >> 32); -} - -static inline __u64 get_mrc_cr_flags(struct mdt_rec_create *mrc) -{ - return ((__u64)(mrc->cr_flags_l) | ((__u64)mrc->cr_flags_h << 32)); -} - /* instance of mdt_reint_rec */ struct mdt_rec_link { __u32 lk_opcode; @@ -2403,25 +2392,6 @@ static inline int lmv_mds_md_stripe_count_get(const union lmv_mds_md *lmm) } } -static inline int lmv_mds_md_stripe_count_set(union lmv_mds_md *lmm, - unsigned int stripe_count) -{ - int rc = 0; - - switch (le32_to_cpu(lmm->lmv_magic)) { - case LMV_MAGIC_V1: - lmm->lmv_md_v1.lmv_stripe_count = cpu_to_le32(stripe_count); - break; - case LMV_USER_MAGIC: - lmm->lmv_user_md.lum_stripe_count = cpu_to_le32(stripe_count); - break; - default: - rc = -EINVAL; - break; - } - return rc; -} - enum fld_rpc_opc { FLD_QUERY = 900, FLD_READ = 901, @@ -2502,12 +2472,6 @@ struct ldlm_res_id { #define PLDLMRES(res) (res)->lr_name.name[0], (res)->lr_name.name[1], \ (res)->lr_name.name[2], (res)->lr_name.name[3] -static inline bool ldlm_res_eq(const struct ldlm_res_id *res0, - const struct ldlm_res_id *res1) -{ - return !memcmp(res0, res1, sizeof(*res0)); -} - /* lock types */ enum ldlm_mode { LCK_MINMODE = 0, @@ -2540,19 +2504,6 @@ struct ldlm_extent { __u64 gid; }; -static inline int ldlm_extent_overlap(const struct ldlm_extent *ex1, - const struct ldlm_extent *ex2) -{ - return (ex1->start <= ex2->end) && (ex2->start <= ex1->end); -} - -/* check if @ex1 contains @ex2 */ -static inline int ldlm_extent_contain(const struct ldlm_extent *ex1, - const struct ldlm_extent *ex2) -{ - return (ex1->start <= ex2->start) && (ex1->end >= ex2->end); -} - struct ldlm_inodebits { __u64 bits; }; @@ -2627,18 +2578,6 @@ struct ldlm_request { struct lustre_handle lock_handle[LDLM_LOCKREQ_HANDLES]; }; -/* If LDLM_ENQUEUE, 1 slot is already occupied, 1 is available. - * Otherwise, 2 are available. - */ -#define ldlm_request_bufsize(count, type) \ -({ \ - int _avail = LDLM_LOCKREQ_HANDLES; \ - _avail -= (type == LDLM_ENQUEUE ? LDLM_ENQUEUE_CANCEL_OFF : 0); \ - sizeof(struct ldlm_request) + \ - (count > _avail ? count - _avail : 0) * \ - sizeof(struct lustre_handle); \ -}) - struct ldlm_reply { __u32 lock_flags; __u32 lock_padding; /* also fix lustre_swab_ldlm_reply */ @@ -2942,12 +2881,6 @@ static inline const char *agent_req_status2name(const enum agent_req_status ars) } } -static inline bool agent_req_in_final_state(enum agent_req_status ars) -{ - return ((ars == ARS_SUCCEED) || (ars == ARS_FAILED) || - (ars == ARS_CANCELED)); -} - struct llog_agent_req_rec { struct llog_rec_hdr arr_hdr; /**< record header */ __u32 arr_status; /**< status of the request */ @@ -3142,12 +3075,6 @@ struct ll_fiemap_info_key { struct fiemap lfik_fiemap; }; -/* Functions for dumping PTLRPC fields */ -void dump_rniobuf(struct niobuf_remote *rnb); -void dump_ioo(struct obd_ioobj *nb); -void dump_ost_body(struct ost_body *ob); -void dump_rcs(__u32 *rc); - /* security opcodes */ enum sec_cmd { SEC_CTX_INIT = 801, diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index b7e61d0..0d7eb80 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -1339,5 +1339,18 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock *lock); /** @} */ +static inline int ldlm_extent_overlap(const struct ldlm_extent *ex1, + const struct ldlm_extent *ex2) +{ + return ex1->start <= ex2->end && ex2->start <= ex1->end; +} + +/* check if @ex1 contains @ex2 */ +static inline int ldlm_extent_contain(const struct ldlm_extent *ex1, + const struct ldlm_extent *ex2) +{ + return ex1->start <= ex2->start && ex1->end >= ex2->end; +} + #endif /** @} LDLM */ diff --git a/drivers/staging/lustre/lustre/include/lustre_swab.h b/drivers/staging/lustre/lustre/include/lustre_swab.h index 26d01c2..5c1bdc0 100644 --- a/drivers/staging/lustre/lustre/include/lustre_swab.h +++ b/drivers/staging/lustre/lustre/include/lustre_swab.h @@ -99,4 +99,10 @@ void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod, void lustre_swab_close_data(struct close_data *data); void lustre_swab_lmv_user_md(struct lmv_user_md *lum); +/* Functions for dumping PTLRPC fields */ +void dump_rniobuf(struct niobuf_remote *rnb); +void dump_ioo(struct obd_ioobj *nb); +void dump_ost_body(struct ost_body *ob); +void dump_rcs(__u32 *rc); + #endif diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 5c02501..d3a9609 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -334,3 +334,9 @@ void ldlm_flock_policy_wire_to_local(const union ldlm_wire_policy_data *wpolicy, union ldlm_policy_data *lpolicy); void ldlm_flock_policy_local_to_wire(const union ldlm_policy_data *lpolicy, union ldlm_wire_policy_data *wpolicy); + +static inline bool ldlm_res_eq(const struct ldlm_res_id *res0, + const struct ldlm_res_id *res1) +{ + return memcmp(res0, res1, sizeof(*res0)) == 0; +} diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index c1f8693..cd6614b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -83,6 +83,33 @@ struct ldlm_async_args { struct lustre_handle lock_handle; }; +/** + * ldlm_request_bufsize + * + * @count: number of ldlm handles + * @type: ldlm opcode + * + * If opcode=LDLM_ENQUEUE, 1 slot is already occupied, + * LDLM_LOCKREQ_HANDLE -1 slots are available. + * Otherwise, LDLM_LOCKREQ_HANDLE slots are available. + * + * Return: size of the request buffer + */ +int ldlm_request_bufsize(int count, int type) +{ + int avail = LDLM_LOCKREQ_HANDLES; + + if (type == LDLM_ENQUEUE) + avail -= LDLM_ENQUEUE_CANCEL_OFF; + + if (count > avail) + avail = (count - avail) * sizeof(struct lustre_handle); + else + avail = 0; + + return sizeof(struct ldlm_request) + avail; +} + static int ldlm_expired_completion_wait(void *data) { struct lock_wait_data *lwd = data; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index f35e1f9..4e55255 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -35,6 +35,12 @@ #include "../include/lustre/lustre_idl.h" #include "mdc_internal.h" +static void set_mrc_cr_flags(struct mdt_rec_create *mrc, u64 flags) +{ + mrc->cr_flags_l = (u32)(flags & 0xFFFFFFFFUll); + mrc->cr_flags_h = (u32)(flags >> 32); +} + static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid) { b->mbo_suppgid = suppgid; -- 1.8.3.1 From jsimmons at infradead.org Sat Dec 10 18:05:59 2016 From: jsimmons at infradead.org (James Simmons) Date: Sat, 10 Dec 2016 13:05:59 -0500 Subject: [lustre-devel] [PATCH v2 3/5] staging: lustre: headers: sort headers affected by obdo move In-Reply-To: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> Message-ID: <1481393161-22623-4-git-send-email-jsimmons@infradead.org> From: Ben Evans It was found if you sort the headers alphabetically that it reduced patch conflicts. This patch sorts the headers alphabetically and also place linux header first, then uapi header and finally the lustre kernel headers. Signed-off-by: Ben Evans Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6401 Reviewed-on: http://review.whamcloud.com/16917 Reviewed-on: http://review.whamcloud.com/19266 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- Changelog: v1) Initial patch v2) rebase patch against newer base patch that now includes lustre_obdo.h in osc_request.c. drivers/staging/lustre/lustre/osc/osc_request.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 99aefa5..0273ccd 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -34,20 +34,21 @@ #include "../../include/linux/libcfs/libcfs.h" -#include "../include/lustre_dlm.h" -#include "../include/lustre_net.h" +#include "../include/lustre/lustre_ioctl.h" #include "../include/lustre/lustre_user.h" -#include "../include/obd_cksum.h" -#include "../include/lustre_ha.h" #include "../include/lprocfs_status.h" -#include "../include/lustre/lustre_ioctl.h" #include "../include/lustre_debug.h" +#include "../include/lustre_dlm.h" +#include "../include/lustre_fid.h" +#include "../include/lustre_ha.h" +#include "../include/lustre_net.h" #include "../include/lustre_obdo.h" #include "../include/lustre_param.h" -#include "../include/lustre_fid.h" -#include "../include/obd_class.h" #include "../include/obd.h" +#include "../include/obd_cksum.h" +#include "../include/obd_class.h" + #include "osc_internal.h" #include "osc_cl_internal.h" -- 1.8.3.1 From jsimmons at infradead.org Sat Dec 10 18:05:57 2016 From: jsimmons at infradead.org (James Simmons) Date: Sat, 10 Dec 2016 13:05:57 -0500 Subject: [lustre-devel] [PATCH v2 1/5] staging: lustre: obdclass: Create a header for obdo related functions In-Reply-To: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> Message-ID: <1481393161-22623-2-git-send-email-jsimmons@infradead.org> From: Ben Evans Remove all obdo related functions from lustre_idl.h Create lustre_odbo.h. Include where appropriate. Make the functions lustre_get_wire_obdo and lustre_set_wire_obdo to not be inlined functions. Signed-off-by: Ben Evans Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6401 Reviewed-on: http://review.whamcloud.com/16917 Reviewed-on: http://review.whamcloud.com/19266 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- Changelog: v1) Initial patch from earlier version that broke build v2) Include lustre_obdo.h to osc_request.c so it can build. Next move style changes from moved functions to separate patch. .../lustre/lustre/include/lustre/lustre_idl.h | 46 ------------------ .../staging/lustre/lustre/include/lustre_obdo.h | 54 ++++++++++++++++++++++ drivers/staging/lustre/lustre/obdclass/obdo.c | 53 +++++++++++++++++++++ drivers/staging/lustre/lustre/osc/osc_io.c | 2 + drivers/staging/lustre/lustre/osc/osc_request.c | 1 + 5 files changed, 110 insertions(+), 46 deletions(-) create mode 100644 drivers/staging/lustre/lustre/include/lustre_obdo.h diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 65ce503..b0eb80d 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -3130,52 +3130,6 @@ struct obdo { #define o_cksum o_nlink #define o_grant_used o_data_version -static inline void lustre_set_wire_obdo(const struct obd_connect_data *ocd, - struct obdo *wobdo, - const struct obdo *lobdo) -{ - *wobdo = *lobdo; - wobdo->o_flags &= ~OBD_FL_LOCAL_MASK; - if (!ocd) - return; - - if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && - fid_seq_is_echo(ostid_seq(&lobdo->o_oi))) { - /* Currently OBD_FL_OSTID will only be used when 2.4 echo - * client communicate with pre-2.4 server - */ - wobdo->o_oi.oi.oi_id = fid_oid(&lobdo->o_oi.oi_fid); - wobdo->o_oi.oi.oi_seq = fid_seq(&lobdo->o_oi.oi_fid); - } -} - -static inline void lustre_get_wire_obdo(const struct obd_connect_data *ocd, - struct obdo *lobdo, - const struct obdo *wobdo) -{ - __u32 local_flags = 0; - - if (lobdo->o_valid & OBD_MD_FLFLAGS) - local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; - - *lobdo = *wobdo; - if (local_flags != 0) { - lobdo->o_valid |= OBD_MD_FLFLAGS; - lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; - lobdo->o_flags |= local_flags; - } - if (!ocd) - return; - - if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && - fid_seq_is_echo(wobdo->o_oi.oi.oi_seq)) { - /* see above */ - lobdo->o_oi.oi_fid.f_seq = wobdo->o_oi.oi.oi_seq; - lobdo->o_oi.oi_fid.f_oid = wobdo->o_oi.oi.oi_id; - lobdo->o_oi.oi_fid.f_ver = 0; - } -} - /* request structure for OST's */ struct ost_body { struct obdo oa; diff --git a/drivers/staging/lustre/lustre/include/lustre_obdo.h b/drivers/staging/lustre/lustre/include/lustre_obdo.h new file mode 100644 index 0000000..1e12f8c --- /dev/null +++ b/drivers/staging/lustre/lustre/include/lustre_obdo.h @@ -0,0 +1,54 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2014, Intel Corporation. + * + * Copyright 2015 Cray Inc, all rights reserved. + * Author: Ben Evans. + * + * Define obdo associated functions + * obdo: OBject Device o... + */ + +#ifndef _LUSTRE_OBDO_H_ +#define _LUSTRE_OBDO_H_ + +#include "lustre/lustre_idl.h" + +/** + * Create an obdo to send over the wire + */ +void lustre_set_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *wobdo, + const struct obdo *lobdo); + +/** + * Create a local obdo from a wire based odbo + */ +void lustre_get_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *lobdo, + const struct obdo *wobdo); + +#endif diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index c52b9e0..241e60b 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -40,6 +40,7 @@ #include "../include/obd_class.h" #include "../include/lustre/lustre_idl.h" +#include "../include/lustre_obdo.h" void obdo_set_parent_fid(struct obdo *dst, const struct lu_fid *parent) { @@ -124,3 +125,55 @@ void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj) ioobj->ioo_max_brw = 0; } EXPORT_SYMBOL(obdo_to_ioobj); + +/** + * Create an obdo to send over the wire + */ +void lustre_set_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *wobdo, const struct obdo *lobdo) +{ + *wobdo = *lobdo; + wobdo->o_flags &= ~OBD_FL_LOCAL_MASK; + if (!ocd) + return; + + if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && + fid_seq_is_echo(ostid_seq(&lobdo->o_oi))) { + /* Currently OBD_FL_OSTID will only be used when 2.4 echo + * client communicate with pre-2.4 server + */ + wobdo->o_oi.oi.oi_id = fid_oid(&lobdo->o_oi.oi_fid); + wobdo->o_oi.oi.oi_seq = fid_seq(&lobdo->o_oi.oi_fid); + } +} +EXPORT_SYMBOL(lustre_set_wire_obdo); + +/** + * Create a local obdo from a wire based odbo + */ +void lustre_get_wire_obdo(const struct obd_connect_data *ocd, + struct obdo *lobdo, const struct obdo *wobdo) +{ + __u32 local_flags = 0; + + if (lobdo->o_valid & OBD_MD_FLFLAGS) + local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK; + + *lobdo = *wobdo; + if (local_flags != 0) { + lobdo->o_valid |= OBD_MD_FLFLAGS; + lobdo->o_flags &= ~OBD_FL_LOCAL_MASK; + lobdo->o_flags |= local_flags; + } + if (!ocd) + return; + + if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) && + fid_seq_is_echo(wobdo->o_oi.oi.oi_seq)) { + /* see above */ + lobdo->o_oi.oi_fid.f_seq = wobdo->o_oi.oi.oi_seq; + lobdo->o_oi.oi_fid.f_oid = wobdo->o_oi.oi.oi_id; + lobdo->o_oi.oi_fid.f_ver = 0; + } +} +EXPORT_SYMBOL(lustre_get_wire_obdo); diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 228a97c..164aec3 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -37,6 +37,8 @@ #define DEBUG_SUBSYSTEM S_OSC +#include "../include/lustre_obdo.h" + #include "osc_cl_internal.h" /** \addtogroup osc diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 7143564..99aefa5 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -43,6 +43,7 @@ #include "../include/lprocfs_status.h" #include "../include/lustre/lustre_ioctl.h" #include "../include/lustre_debug.h" +#include "../include/lustre_obdo.h" #include "../include/lustre_param.h" #include "../include/lustre_fid.h" #include "../include/obd_class.h" -- 1.8.3.1 From gregkh at linuxfoundation.org Sat Dec 10 18:14:33 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Sat, 10 Dec 2016 19:14:33 +0100 Subject: [lustre-devel] [PATCH v2 3/5] staging: lustre: headers: sort headers affected by obdo move In-Reply-To: <1481393161-22623-4-git-send-email-jsimmons@infradead.org> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-4-git-send-email-jsimmons@infradead.org> Message-ID: <20161210181433.GA8477@kroah.com> On Sat, Dec 10, 2016 at 01:05:59PM -0500, James Simmons wrote: > From: Ben Evans > > It was found if you sort the headers alphabetically > that it reduced patch conflicts. This patch sorts > the headers alphabetically and also place linux > header first, then uapi header and finally the > lustre kernel headers. I still don't agree, when did you last have a patch conflict with this file in the .h section? And exactly how hard was it to fix it up? I'm all for cleanups, but really, this is useless. And I said so the last time you sent it... greg k-h From gregkh at linuxfoundation.org Sat Dec 10 18:16:49 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Sat, 10 Dec 2016 19:16:49 +0100 Subject: [lustre-devel] [PATCH v2 5/5] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: <1481393161-22623-6-git-send-email-jsimmons@infradead.org> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-6-git-send-email-jsimmons@infradead.org> Message-ID: <20161210181649.GB8477@kroah.com> On Sat, Dec 10, 2016 at 01:06:01PM -0500, James Simmons wrote: > In order for lustre_idl.h to be usable for both user > land and kernel space it has to use the proper > byteorder functions. Why would userspace need/want all of these inline functions? A uapi header file should just have a the structures that are passed user/kernel and any needed ioctls. Why would they ever care about strange byte flip functions and a ton of inline functions? I don't think this is needed, of if it is, I really don't want to see your crazy userspace code... thanks, greg k-h From bevans at cray.com Mon Dec 12 14:42:29 2016 From: bevans at cray.com (Ben Evans) Date: Mon, 12 Dec 2016 14:42:29 +0000 Subject: [lustre-devel] [PATCH v2 3/5] staging: lustre: headers: sort headers affected by obdo move In-Reply-To: <20161210181433.GA8477@kroah.com> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-4-git-send-email-jsimmons@infradead.org> <20161210181433.GA8477@kroah.com> Message-ID: This was done to conform to the Lustre Coding Guidelines. -Ben On 12/10/16, 1:14 PM, "Greg Kroah-Hartman" wrote: >On Sat, Dec 10, 2016 at 01:05:59PM -0500, James Simmons wrote: >> From: Ben Evans >> >> It was found if you sort the headers alphabetically >> that it reduced patch conflicts. This patch sorts >> the headers alphabetically and also place linux >> header first, then uapi header and finally the >> lustre kernel headers. > >I still don't agree, when did you last have a patch conflict with this >file in the .h section? And exactly how hard was it to fix it up? > >I'm all for cleanups, but really, this is useless. And I said so the >last time you sent it... > >greg k-h From gregkh at linuxfoundation.org Mon Dec 12 16:34:55 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Mon, 12 Dec 2016 17:34:55 +0100 Subject: [lustre-devel] [PATCH v2 3/5] staging: lustre: headers: sort headers affected by obdo move In-Reply-To: References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-4-git-send-email-jsimmons@infradead.org> <20161210181433.GA8477@kroah.com> Message-ID: <20161212163455.GA21011@kroah.com> A: Top-posting. Q: What is the most annoying thing in e-mail? A: No. Q: Should I include quotations after my reply? http://daringfireball.net/2007/07/on_top On Mon, Dec 12, 2016 at 02:42:29PM +0000, Ben Evans wrote: > This was done to conform to the Lustre Coding Guidelines. What is this mythical guidelines, and why does it differ from the kernel source ones? And again, why is this patch required? thanks, greg k-h From bevans at cray.com Mon Dec 12 18:12:06 2016 From: bevans at cray.com (Ben Evans) Date: Mon, 12 Dec 2016 18:12:06 +0000 Subject: [lustre-devel] [PATCH v2 3/5] staging: lustre: headers: sort headers affected by obdo move In-Reply-To: <20161212163455.GA21011@kroah.com> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-4-git-send-email-jsimmons@infradead.org> <20161210181433.GA8477@kroah.com> <20161212163455.GA21011@kroah.com> Message-ID: On 12/12/16, 11:34 AM, "Greg Kroah-Hartman" wrote: >What is this mythical guidelines, and why does it differ from the kernel >source ones? > >And again, why is this patch required? > >thanks, > >greg k-h > Here are the general guidelines for your reading pleasure: http://wiki.lustre.org/Lustre_Coding_Style_Guidelines The specific guidelines on organizing #includes are here: http://wiki.lustre.org/Lustre_Style_Guide_Includes -Ben Evans From joe at perches.com Mon Dec 12 18:19:06 2016 From: joe at perches.com (Joe Perches) Date: Mon, 12 Dec 2016 10:19:06 -0800 Subject: [lustre-devel] [PATCH v2 3/5] staging: lustre: headers: sort headers affected by obdo move In-Reply-To: <20161212163455.GA21011@kroah.com> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-4-git-send-email-jsimmons@infradead.org> <20161210181433.GA8477@kroah.com> <20161212163455.GA21011@kroah.com> Message-ID: <1481566746.1764.26.camel@perches.com> On Mon, 2016-12-12 at 17:34 +0100, Greg Kroah-Hartman wrote: > A: Top-posting. > Q: What is the most annoying thing in e-mail? > > A: No. > Q: Should I include quotations after my reply? > > http://daringfireball.net/2007/07/on_top > > On Mon, Dec 12, 2016 at 02:42:29PM +0000, Ben Evans wrote: > > This was done to conform to the Lustre Coding Guidelines. > > What is this mythical guidelines, and why does it differ from the kernel > source ones? It's not like it's hard to find http://wiki.lustre.org/Lustre_Coding_Style_Guidelines And in specific: http://wiki.lustre.org/Lustre_Style_Guide_Includes There is no single mandated code style for this. Some people like reverse christmas tree. Whatever... From jsimmons at infradead.org Mon Dec 12 19:41:41 2016 From: jsimmons at infradead.org (James Simmons) Date: Mon, 12 Dec 2016 19:41:41 +0000 (GMT) Subject: [lustre-devel] [PATCH v2 3/5] staging: lustre: headers: sort headers affected by obdo move In-Reply-To: <1481566746.1764.26.camel@perches.com> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-4-git-send-email-jsimmons@infradead.org> <20161210181433.GA8477@kroah.com> <20161212163455.GA21011@kroah.com> <1481566746.1764.26.camel@perches.com> Message-ID: > On Mon, 2016-12-12 at 17:34 +0100, Greg Kroah-Hartman wrote: > > A: Top-posting. > > Q: What is the most annoying thing in e-mail? > > > > A: No. > > Q: Should I include quotations after my reply? > > > > http://daringfireball.net/2007/07/on_top > > > > On Mon, Dec 12, 2016 at 02:42:29PM +0000, Ben Evans wrote: > > > This was done to conform to the Lustre Coding Guidelines. > > > > What is this mythical guidelines, and why does it differ from the kernel > > source ones? > > It's not like it's hard to find > http://wiki.lustre.org/Lustre_Coding_Style_Guidelines > > And in specific: > http://wiki.lustre.org/Lustre_Style_Guide_Includes > > There is no single mandated code style for this. > Some people like reverse christmas tree. > > Whatever... > Sigh, Sayre's law. I went looking to see what the offical policy is for this and found nothing. If this is really important can we then place an offical policy on how headers are added to a C file in CodingStyle and add something to checkpatch to detect incorrect patches. Lets burn down this bike shed once and for all. From joe at perches.com Mon Dec 12 19:52:00 2016 From: joe at perches.com (Joe Perches) Date: Mon, 12 Dec 2016 11:52:00 -0800 Subject: [lustre-devel] [PATCH v2 3/5] staging: lustre: headers: sort headers affected by obdo move In-Reply-To: References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-4-git-send-email-jsimmons@infradead.org> <20161210181433.GA8477@kroah.com> <20161212163455.GA21011@kroah.com> <1481566746.1764.26.camel@perches.com> Message-ID: <1481572320.1764.35.camel@perches.com> On Mon, 2016-12-12 at 19:41 +0000, James Simmons wrote: > > On Mon, 2016-12-12 at 17:34 +0100, Greg Kroah-Hartman wrote: [] > > http://wiki.lustre.org/Lustre_Style_Guide_Includes > > > > There is no single mandated code style for this. > > Some people like reverse christmas tree. > > > > Whatever... > > > Sigh, Sayre's law. > I went looking to see what the offical > policy is for this and found nothing. If this is really > important can we then place an offical policy on how > headers are added to a C file in CodingStyle and add > something to checkpatch to detect incorrect patches. > Lets burn down this bike shed once and for all. g'luck with that. David Miller might like to have a word with you too. From jsimmons at infradead.org Mon Dec 12 20:00:02 2016 From: jsimmons at infradead.org (James Simmons) Date: Mon, 12 Dec 2016 20:00:02 +0000 (GMT) Subject: [lustre-devel] [PATCH v2 5/5] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: <20161210181649.GB8477@kroah.com> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-6-git-send-email-jsimmons@infradead.org> <20161210181649.GB8477@kroah.com> Message-ID: > On Sat, Dec 10, 2016 at 01:06:01PM -0500, James Simmons wrote: > > In order for lustre_idl.h to be usable for both user > > land and kernel space it has to use the proper > > byteorder functions. > > Why would userspace need/want all of these inline functions? A uapi > header file should just have a the structures that are passed > user/kernel and any needed ioctls. Why would they ever care about > strange byte flip functions and a ton of inline functions? > > I don't think this is needed, of if it is, I really don't want to see > your crazy userspace code... Sigh. More cleanups were done based on the idea this was okay. The reason this was does was when you look at the headers in include/uapi/linux you see a huge number of headers containing a bunch of inline function. To an outside project looking to merge their work into the kernel they would think this is okay. Hopefully all those broken headers will be cleaned up in the near future. Alright I will look to fixing up our tools to handle this requirement. From gregkh at linuxfoundation.org Tue Dec 13 00:37:28 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Mon, 12 Dec 2016 16:37:28 -0800 Subject: [lustre-devel] [PATCH v2 5/5] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-6-git-send-email-jsimmons@infradead.org> <20161210181649.GB8477@kroah.com> Message-ID: <20161213003728.GA3052@kroah.com> On Mon, Dec 12, 2016 at 08:00:02PM +0000, James Simmons wrote: > > > On Sat, Dec 10, 2016 at 01:06:01PM -0500, James Simmons wrote: > > > In order for lustre_idl.h to be usable for both user > > > land and kernel space it has to use the proper > > > byteorder functions. > > > > Why would userspace need/want all of these inline functions? A uapi > > header file should just have a the structures that are passed > > user/kernel and any needed ioctls. Why would they ever care about > > strange byte flip functions and a ton of inline functions? > > > > I don't think this is needed, of if it is, I really don't want to see > > your crazy userspace code... > > Sigh. More cleanups were done based on the idea this was okay. The reason > this was does was when you look at the headers in include/uapi/linux you > see a huge number of headers containing a bunch of inline function. To > an outside project looking to merge their work into the kernel they would > think this is okay. Hopefully all those broken headers will be cleaned > up in the near future. Alright I will look to fixing up our tools to > handle this requirement. But why do you need this type of stuff at all for your userspace code? Why do they need these "complex" inline functions? That implies that there is duplicated logic on both sides of the user/kernel boundry, shouldn't that be resolved somehow? thanks, greg k-h From andreas.dilger at intel.com Tue Dec 13 00:55:01 2016 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Tue, 13 Dec 2016 00:55:01 +0000 Subject: [lustre-devel] [PATCH v2 5/5] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-6-git-send-email-jsimmons@infradead.org> <20161210181649.GB8477@kroah.com> Message-ID: <73FD0668-EDE9-4757-98ED-8A15CE5DA17C@intel.com> On Dec 12, 2016, at 13:00, James Simmons wrote: > > >> On Sat, Dec 10, 2016 at 01:06:01PM -0500, James Simmons wrote: >>> In order for lustre_idl.h to be usable for both user >>> land and kernel space it has to use the proper >>> byteorder functions. >> >> Why would userspace need/want all of these inline functions? A uapi >> header file should just have a the structures that are passed >> user/kernel and any needed ioctls. Why would they ever care about >> strange byte flip functions and a ton of inline functions? >> >> I don't think this is needed, of if it is, I really don't want to see >> your crazy userspace code... > > Sigh. More cleanups were done based on the idea this was okay. The > reason this was does was when you look at the headers in > include/uapi/linux you see a huge number of headers containing a bunch > of inline function. To an outside project looking to merge their work > into the kernel they would think this is okay. Hopefully all those > broken headers will be cleaned up in the near future. > Alright I will look to fixing up our tools to handle this requirement. These accessor functions are used by both the kernel and userspace tools, and keeping them in the lustre_idl.h header avoids duplication of code. Similar usage exists in other filesystem related uapi headers (e.g. auto_fs4.h, bcache.h, btrfs_tree.h, nilfs2_ondisk.h, swab.h, etc.). That said, if there is an objection to keeping these macros/inline funcs in the uapi headers, they still need to exist in the kernel and should be kept in the lustre/include/lustre directory and we'll keep a separate copy of the macros for userspace. Cheers, Andreas From gregkh at linuxfoundation.org Tue Dec 13 01:07:00 2016 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Mon, 12 Dec 2016 17:07:00 -0800 Subject: [lustre-devel] [PATCH v2 5/5] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: <73FD0668-EDE9-4757-98ED-8A15CE5DA17C@intel.com> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-6-git-send-email-jsimmons@infradead.org> <20161210181649.GB8477@kroah.com> <73FD0668-EDE9-4757-98ED-8A15CE5DA17C@intel.com> Message-ID: <20161213010700.GA21619@kroah.com> On Tue, Dec 13, 2016 at 12:55:01AM +0000, Dilger, Andreas wrote: > On Dec 12, 2016, at 13:00, James Simmons wrote: > > > > > >> On Sat, Dec 10, 2016 at 01:06:01PM -0500, James Simmons wrote: > >>> In order for lustre_idl.h to be usable for both user > >>> land and kernel space it has to use the proper > >>> byteorder functions. > >> > >> Why would userspace need/want all of these inline functions? A uapi > >> header file should just have a the structures that are passed > >> user/kernel and any needed ioctls. Why would they ever care about > >> strange byte flip functions and a ton of inline functions? > >> > >> I don't think this is needed, of if it is, I really don't want to see > >> your crazy userspace code... > > > > Sigh. More cleanups were done based on the idea this was okay. The > > reason this was does was when you look at the headers in > > include/uapi/linux you see a huge number of headers containing a bunch > > of inline function. To an outside project looking to merge their work > > into the kernel they would think this is okay. Hopefully all those > > broken headers will be cleaned up in the near future. > > Alright I will look to fixing up our tools to handle this requirement. > > These accessor functions are used by both the kernel and userspace > tools, and keeping them in the lustre_idl.h header avoids duplication > of code. Similar usage exists in other filesystem related uapi headers > (e.g. auto_fs4.h, bcache.h, btrfs_tree.h, nilfs2_ondisk.h, swab.h, etc.). > > That said, if there is an objection to keeping these macros/inline funcs > in the uapi headers, they still need to exist in the kernel and should > be kept in the lustre/include/lustre directory and we'll keep a separate > copy of the macros for userspace. "simple" accessors/setters are fine, but these start to get complex, you are using unlikely, and debug macros and lots of other fun stuff. Do all other filesystems also do complex stuff like ostid_to_fid()? thanks, greg k-h From green at linuxhacker.ru Tue Dec 13 04:07:53 2016 From: green at linuxhacker.ru (Oleg Drokin) Date: Mon, 12 Dec 2016 23:07:53 -0500 Subject: [lustre-devel] [PATCH 0/8] Sparse warning fixes in Lustre. In-Reply-To: <20161207234639.GU1555@ZenIV.linux.org.uk> References: <1481150494-1853127-1-git-send-email-green@linuxhacker.ru> <20161207234639.GU1555@ZenIV.linux.org.uk> Message-ID: <8062BE1A-1674-4643-92C4-1E0A4C6E2477@linuxhacker.ru> On Dec 7, 2016, at 6:46 PM, Al Viro wrote: > On Wed, Dec 07, 2016 at 05:41:26PM -0500, Oleg Drokin wrote: >> This set of fixes aims at sparse warnings. > > Speaking of the stuff sparse catches there: class_process_proc_param(). > I've tried to describe what I think of that Fine Piece Of Software > several times, but I had to give up - my command of obscenity is not > up to the task, neither in English nor in Russian. Please, take it > out. Preferably - along with the ->ldo_process_config()/->process_config() > thing. Well, I can guess what you don't like in the remnants of the "well, we have uniform procfs, so let's use that to our advantage and simplify or config parsing". But what's your beef with ldo_process_config()/->process_config(), I wonder? Just a way to propagate config info across the layers. From dan.carpenter at oracle.com Tue Dec 13 08:31:04 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 13 Dec 2016 11:31:04 +0300 Subject: [lustre-devel] [PATCH v2 5/5] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: <20161213003728.GA3052@kroah.com> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-6-git-send-email-jsimmons@infradead.org> <20161210181649.GB8477@kroah.com> <20161213003728.GA3052@kroah.com> Message-ID: <20161213083104.GD8176@mwanda> It used to be that great swathes of Lustre were used in both user space and kernel space. We had huge unused modules in the kernel that were only used for user space. regards, dan carpenter From quentin.bouget at cea.fr Tue Dec 13 10:02:06 2016 From: quentin.bouget at cea.fr (quentin.bouget at cea.fr) Date: Tue, 13 Dec 2016 11:02:06 +0100 Subject: [lustre-devel] caching in Lustre Message-ID: <6cac83b6-3d70-a814-3b12-54ea51386296@cea.fr> Hi all, I am currently trying to work out how Lustre behaves when both "read_cache" and "writethrough_cache" are disabled. What I particularly want to know is how does writing to the related proc files influence the cache policy? To me (and perf_event reports it too on a 2.7 setup), the code always gets cache pages (using find_or_create_page() in "lustre/osd-ldiskfs/osd_io.c") even with both cache parameters set to 0. After that, if caching is disabled, a call to generic_error_remove_page() is issued on the pages that were allocated. This functions is described in the kernel sources like this: *//* * Used to get rid of pages on hardware memory corruption. */ int generic_error_remove_page(struct adress_space *mapping, struct page *page) /* This does not seem to be the "natural" call to use, but anyway, I can live with that. What really bothers me is that the behaviour of Lustre from this point looks exactly the same as if cache was enabled. I can't find a single branching point that handles things differently: pages are kmapped, written to/read from, kunmmaped... I am probably missing something, but I can't figure out what. Could someone please point me in the right direction? The functions I find the most relevant to study are: "lustre/ofd/ofd_io.c": ofd_preprw() -> ofd_preprw_read() / ofd_preprw_write() their counterparts: "lustre/ofd/ofd_io.c": ofd_commitrw() -> ofd_commitrw_read() / ofd_commitrw_write() the handlers of the proc files "/proc/fs/lustre/obdfilter/*/{read,writethrough}_cache_enable": "lustre/osd-ldiskfs/osd_lproc.c": ldiskfs_osd_cache_seq_write(), ldiskfs_osd_wcache_seq_write() and the only places that use the variables set by the proc files (where generic_error_remove_page() is used): "lustre/osd-ldiskfs/osd_io.c": osd_read_prep(), osd_write_prep() (I suspect I am missing something really important about what generic_error_remove_page() does) Regards Quentin Bouget -------------- next part -------------- An HTML attachment was scrubbed... URL: From paf at cray.com Tue Dec 13 13:33:13 2016 From: paf at cray.com (Patrick Farrell) Date: Tue, 13 Dec 2016 13:33:13 +0000 Subject: [lustre-devel] caching in Lustre In-Reply-To: <6cac83b6-3d70-a814-3b12-54ea51386296@cea.fr> References: <6cac83b6-3d70-a814-3b12-54ea51386296@cea.fr> Message-ID: Quentin, I suspect that the pages are only maintained during the duration of an IO, then discarded. I haven't dug in to the exact mechanics of it, but when caches are disabled, the key thing is no CACHING occurs, i.e., nothing can be read from the cache. So, I assume, these pages you see are transiently present for purposes of performing the IO. (The data from the disk has to go somewhere.) - Patrick ________________________________ From: lustre-devel on behalf of quentin.bouget at cea.fr Sent: Tuesday, December 13, 2016 4:02:06 AM To: lustre-devel at lists.lustre.org Subject: [lustre-devel] caching in Lustre Hi all, I am currently trying to work out how Lustre behaves when both "read_cache" and "writethrough_cache" are disabled. What I particularly want to know is how does writing to the related proc files influence the cache policy? To me (and perf_event reports it too on a 2.7 setup), the code always gets cache pages (using find_or_create_page() in "lustre/osd-ldiskfs/osd_io.c") even with both cache parameters set to 0. After that, if caching is disabled, a call to generic_error_remove_page() is issued on the pages that were allocated. This functions is described in the kernel sources like this: /* * Used to get rid of pages on hardware memory corruption. */ int generic_error_remove_page(struct adress_space *mapping, struct page *page) This does not seem to be the "natural" call to use, but anyway, I can live with that. What really bothers me is that the behaviour of Lustre from this point looks exactly the same as if cache was enabled. I can't find a single branching point that handles things differently: pages are kmapped, written to/read from, kunmmaped... I am probably missing something, but I can't figure out what. Could someone please point me in the right direction? The functions I find the most relevant to study are: "lustre/ofd/ofd_io.c": ofd_preprw() -> ofd_preprw_read() / ofd_preprw_write() their counterparts: "lustre/ofd/ofd_io.c": ofd_commitrw() -> ofd_commitrw_read() / ofd_commitrw_write() the handlers of the proc files "/proc/fs/lustre/obdfilter/*/{read,writethrough}_cache_enable": "lustre/osd-ldiskfs/osd_lproc.c": ldiskfs_osd_cache_seq_write(), ldiskfs_osd_wcache_seq_write() and the only places that use the variables set by the proc files (where generic_error_remove_page() is used): "lustre/osd-ldiskfs/osd_io.c": osd_read_prep(), osd_write_prep() (I suspect I am missing something really important about what generic_error_remove_page() does) Regards Quentin Bouget -------------- next part -------------- An HTML attachment was scrubbed... URL: From oleg.drokin at intel.com Tue Dec 13 16:14:26 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Tue, 13 Dec 2016 11:14:26 -0500 Subject: [lustre-devel] [PATCH v2 5/5] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: <20161213083104.GD8176@mwanda> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-6-git-send-email-jsimmons@infradead.org> <20161210181649.GB8477@kroah.com> <20161213003728.GA3052@kroah.com> <20161213083104.GD8176@mwanda> Message-ID: On Dec 13, 2016, at 3:31 AM, Dan Carpenter wrote: > It used to be that great swathes of Lustre were used in both user space > and kernel space. We had huge unused modules in the kernel that were > only used for user space. Huh? There was nothing of the sort. There were huge parts of code that were used by the server, but sue to no server in staging client, ended up being unused, though. There were also (much smaller) bits that were supporting userspace client (that is, a library that was able to mount lustre servers completely from userspace by hijacking libc calls), but that was mostly gone by the time we got into staging anyway. From dan.carpenter at oracle.com Tue Dec 13 17:21:40 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 13 Dec 2016 20:21:40 +0300 Subject: [lustre-devel] [PATCH v2 5/5] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-6-git-send-email-jsimmons@infradead.org> <20161210181649.GB8477@kroah.com> <20161213003728.GA3052@kroah.com> <20161213083104.GD8176@mwanda> Message-ID: <20161213172140.GG8176@mwanda> On Tue, Dec 13, 2016 at 11:14:26AM -0500, Oleg Drokin wrote: > > On Dec 13, 2016, at 3:31 AM, Dan Carpenter wrote: > > > It used to be that great swathes of Lustre were used in both user space > > and kernel space. We had huge unused modules in the kernel that were > > only used for user space. > > Huh? > There was nothing of the sort. > There were huge parts of code that were used by the server, but sue to no server > in staging client, ended up being unused, though. > Oh. Right, that's it. regards, dan carpenter From quentin.bouget at cea.fr Wed Dec 14 16:21:39 2016 From: quentin.bouget at cea.fr (quentin.bouget at cea.fr) Date: Wed, 14 Dec 2016 17:21:39 +0100 Subject: [lustre-devel] caching in Lustre In-Reply-To: References: <6cac83b6-3d70-a814-3b12-54ea51386296@cea.fr> Message-ID: <586fb656-ab88-08d9-6102-400432e7dc5f@cea.fr> Le 13/12/2016 à 14:33, Patrick Farrell a écrit : > > > Quentin, > > I suspect that the pages are only maintained during the duration of an > IO, then discarded. I haven't dug in to the exact mechanics of it, > but when caches are disabled, the key thing is no CACHING occurs, > i.e., nothing can be read from the cache. So, I assume, these pages > you see are transiently present for purposes of performing the IO. > (The data from the disk has to go somewhere.) > > - Patrick > ------------------------------------------------------------------------ > *From:* lustre-devel on behalf > of quentin.bouget at cea.fr > *Sent:* Tuesday, December 13, 2016 4:02:06 AM > *To:* lustre-devel at lists.lustre.org > *Subject:* [lustre-devel] caching in Lustre > > Hi all, > > I am currently trying to work out how Lustre behaves when both > "read_cache" and "writethrough_cache" are disabled. What I > particularly want to know is how does writing to the related proc > files influence the cache policy? > > To me (and perf_event reports it too on a 2.7 setup), the code always > gets cache pages (using find_or_create_page() in > "lustre/osd-ldiskfs/osd_io.c") even with both cache parameters set to 0. > After that, if caching is disabled, a call to > generic_error_remove_page() is issued on the pages that were > allocated. This functions is described in the kernel sources like this: > > *//* * Used to get rid of pages on hardware memory corruption. */ int > generic_error_remove_page(struct adress_space *mapping, struct page > *page) /* > > This does not seem to be the "natural" call to use, but anyway, I can > live with that. > What really bothers me is that the behaviour of Lustre from this point > looks exactly the same as if cache was enabled. I can't find a single > branching point that handles things differently: pages are kmapped, > written to/read from, kunmmaped... I am probably missing something, > but I can't figure out what. Could someone please point me in the > right direction? > > The functions I find the most relevant to study are: > "lustre/ofd/ofd_io.c": > ofd_preprw() -> ofd_preprw_read() / ofd_preprw_write() > > their counterparts: > "lustre/ofd/ofd_io.c": > ofd_commitrw() -> ofd_commitrw_read() / ofd_commitrw_write() > > the handlers of the proc files > "/proc/fs/lustre/obdfilter/*/{read,writethrough}_cache_enable": > "lustre/osd-ldiskfs/osd_lproc.c": > ldiskfs_osd_cache_seq_write(), ldiskfs_osd_wcache_seq_write() > > and the only places that use the variables set by the proc files > (where generic_error_remove_page() is used): > "lustre/osd-ldiskfs/osd_io.c": > osd_read_prep(), osd_write_prep() > > (I suspect I am missing something really important about what > generic_error_remove_page() does) > > > Regards > > Quentin Bouget > Alright, so data has to go somewhere. That makes sense. And those pages are probably discarded as soon as the last reference is dropped (surely on IO completion). So Lustre allocates cache pages, that it sort of converts into "regular" buffers and uses as such. So indeed it mimics a "no_cache" policy... Then, I need to elaborate... I am running obdfilter on Lustre with SSD disks as OST(s). The performance of Lustre seems directly related to the number of threads I configure obdfilter to spawn (the more threads there are, the better). But there is a catch: the more threads I spawn, the more they contends on locks inside the pagecache allocations functions. I reach 100% CPU usage before the theoric throughput of the disks. So I want to see if disabling cache in Lustre provides a better ratio of CPU usage over IO throughput. From there I get confused when I notice that there are still as many calls to find_or_create_page() as with cache enabled, and that my CPU consumption is still maxed out. (I now understand why find_or_create_page() still gets called) Looking at the code of find_or_create_page() it seems to do mainly 2 things: allocate a page, then add it to the LRU list. Yet, removing the page from the LRU list is quite a costly operation. I would have thought that generic_error_remove_page() would take care of it, efficiently, right after initialization, but perf_event shows me that it actually happens when the IO completes -- when the page is released -- and that half the time of one execution of obdfilter-survey is spent spinning there. Would it be imaginable that Lustre used another page allocation function when cache is disabled? Maybe it is even possible to use buffers directly from the ptlrpc requests? Does someone see another way out of this? I tried to be as clear as possible, but I can try again if need be. =) Regards, Quentin Bouget -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.dilger at intel.com Wed Dec 14 21:27:49 2016 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Wed, 14 Dec 2016 21:27:49 +0000 Subject: [lustre-devel] [PATCH] staging : osc : coding style fix In-Reply-To: <1481749884-25674-1-git-send-email-khan.tabrez21@gmail.com> References: <1481749884-25674-1-git-send-email-khan.tabrez21@gmail.com> Message-ID: <96EAFB90-2162-4155-950D-F586EE1DAF87@intel.com> On Dec 14, 2016, at 14:11, Tabrez khan wrote: > > Subject: [PATCH] staging : osc : coding style fix Thanks for sumbitting your patch. As a general rule, the patch summary line should try to describe (as best as possible in a single line) what the patch is actually fixing. It is true this is a "coding style fix" but there are many possible style fixes and it is better to be as specific as space allows. Something like: staging/lustre/osc: remove unnecessary braces or staging/lustre/osc: remove braces from single-line body or staging/lustre/osc: remove braces in osc_release_write_grant() would be more specific. This is doubly important if you are making a large number of similar patches, since it is desirable to have a (relatively) unique summary line for each patch to avoid confusion. > Remove unnecessary braces {} for single if statement block. > This warning is found using checkpatch.pl. The commit body is good. Please resubmit with a new summary line, then you can include: Reviewed-by: Andreas Dilger Cheers, Andreas > Signed-off-by: Tabrez khan > --- > drivers/staging/lustre/lustre/osc/osc_cache.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c > index 4bbe219..5ded31a 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_cache.c > +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c > @@ -1420,10 +1420,8 @@ static void osc_release_write_grant(struct client_obd *cli, > struct brw_page *pga) > { > assert_spin_locked(&cli->cl_loi_list_lock); > - if (!(pga->flag & OBD_BRW_FROM_GRANT)) { > + if (!(pga->flag & OBD_BRW_FROM_GRANT)) > return; > - } > - > pga->flag &= ~OBD_BRW_FROM_GRANT; > atomic_long_dec(&obd_dirty_pages); > cli->cl_dirty_pages--; > -- > 2.7.4 > From gregkh at linuxfoundation.org Thu Dec 15 01:38:34 2016 From: gregkh at linuxfoundation.org (Greg KH) Date: Wed, 14 Dec 2016 17:38:34 -0800 Subject: [lustre-devel] [PATCH] staging : osc : Remove braces from single-line body In-Reply-To: <1481765632-29876-1-git-send-email-khan.tabrez21@gmail.com> References: <1481765632-29876-1-git-send-email-khan.tabrez21@gmail.com> Message-ID: <20161215013834.GA7055@kroah.com> On Thu, Dec 15, 2016 at 07:03:52AM +0530, Tabrez khan wrote: > Remove unnecessary braces {} for single if statement block. > This warning is found using checkpatch.pl. > > Signed-off-by: Tabrez khan > --- > drivers/staging/lustre/lustre/osc/osc_cache.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c > index 4bbe219..5ded31a 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_cache.c > +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c > @@ -1420,10 +1420,8 @@ static void osc_release_write_grant(struct client_obd *cli, > struct brw_page *pga) > { > assert_spin_locked(&cli->cl_loi_list_lock); > - if (!(pga->flag & OBD_BRW_FROM_GRANT)) { > + if (!(pga->flag & OBD_BRW_FROM_GRANT)) > return; > - } > - Why did you also delete the blank line? From gregkh at linuxfoundation.org Thu Dec 15 16:07:46 2016 From: gregkh at linuxfoundation.org (Greg KH) Date: Thu, 15 Dec 2016 08:07:46 -0800 Subject: [lustre-devel] [PATCH] staging : osc : Remove braces from single-line body In-Reply-To: References: <1481765632-29876-1-git-send-email-khan.tabrez21@gmail.com> <20161215013834.GA7055@kroah.com> Message-ID: <20161215160746.GB16790@kroah.com> On Thu, Dec 15, 2016 at 08:09:16PM +0530, Tabrez Khan wrote: > On Thu, Dec 15, 2016 at 7:08 AM, Greg KH wrote: > > On Thu, Dec 15, 2016 at 07:03:52AM +0530, Tabrez khan wrote: > >> Remove unnecessary braces {} for single if statement block. > >> This warning is found using checkpatch.pl. > >> > >> Signed-off-by: Tabrez khan > >> --- > >> drivers/staging/lustre/lustre/osc/osc_cache.c | 4 +--- > >> 1 file changed, 1 insertion(+), 3 deletions(-) > >> > >> diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c > >> index 4bbe219..5ded31a 100644 > >> --- a/drivers/staging/lustre/lustre/osc/osc_cache.c > >> +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c > >> @@ -1420,10 +1420,8 @@ static void osc_release_write_grant(struct client_obd *cli, > >> struct brw_page *pga) > >> { > >> assert_spin_locked(&cli->cl_loi_list_lock); > >> - if (!(pga->flag & OBD_BRW_FROM_GRANT)) { > >> + if (!(pga->flag & OBD_BRW_FROM_GRANT)) > >> return; > >> - } > >> - > > > > Why did you also delete the blank line? > > Because to keep the kernel coding style as close as possible and after > deleting brace it leads to extra empty line so i delete it. > Please guide if done something wrong. The extra blank line is fine, please leave it, it makes the code more readable, don't you think? From joe at perches.com Fri Dec 16 16:05:53 2016 From: joe at perches.com (Joe Perches) Date: Fri, 16 Dec 2016 08:05:53 -0800 Subject: [lustre-devel] [PATCH] staging : lustre : Remove braces from single-line body. In-Reply-To: <1481898571-16842-1-git-send-email-khan.tabrez21@gmail.com> References: <1481898571-16842-1-git-send-email-khan.tabrez21@gmail.com> Message-ID: <1481904353.29291.87.camel@perches.com> On Fri, 2016-12-16 at 19:59 +0530, Tabrez khan wrote: > Remove unnecessary braces {} for single while statement. Your patch is fine Tabrez, but to the lustre folk: > diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c [] > @@ -1371,9 +1371,9 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, LASSERT(atomic_read(&anchor->csi_sync_nr) == 0); /* wait until cl_sync_io_note() has done wakeup */ - while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) { + while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) cpu_relax(); - } + What if the wakeup never occurs/succeeds? Should there be a timeout? From jinshan.xiong at intel.com Fri Dec 16 17:23:03 2016 From: jinshan.xiong at intel.com (Xiong, Jinshan) Date: Fri, 16 Dec 2016 17:23:03 +0000 Subject: [lustre-devel] [PATCH] staging : lustre : Remove braces from single-line body. In-Reply-To: <1481904353.29291.87.camel@perches.com> References: <1481898571-16842-1-git-send-email-khan.tabrez21@gmail.com> <1481904353.29291.87.camel@perches.com> Message-ID: > On Dec 16, 2016, at 8:05 AM, Joe Perches wrote: > > On Fri, 2016-12-16 at 19:59 +0530, Tabrez khan wrote: >> Remove unnecessary braces {} for single while statement. > > Your patch is fine Tabrez, but to the lustre folk: > >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c > [] >> @@ -1371,9 +1371,9 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, > LASSERT(atomic_read(&anchor->csi_sync_nr) == 0); > > /* wait until cl_sync_io_note() has done wakeup */ > - while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) { > + while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) > cpu_relax(); > - } > + > > What if the wakeup never occurs/succeeds? > Should there be a timeout? There is no wakeup at all. This piece of code is to solve the preempting race condition in cl_sync_io_end(), where it calls wake_up_all() to wake up the cl_sync_io_wait() process, and then is preempted _inside_ wake_up_all(), and then cl_sync_io_wait() process gains the CPU and frees memory cl_sync_io. Therefore when cl_sync_io_end() comes back to finish its work in wake_up_all(), a piece of freed memory will be accessed. csi_barrier is proposed to solve this problem, which makes sure wake_up_all() is complete before cl_sync_io_wait() can continue. It should be a really short time so it’s reasonable for cl_sync_io_wait() to do a busy loop wait. Jinshan > _______________________________________________ > lustre-devel mailing list > lustre-devel at lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org From joe at perches.com Fri Dec 16 18:43:24 2016 From: joe at perches.com (Joe Perches) Date: Fri, 16 Dec 2016 10:43:24 -0800 Subject: [lustre-devel] [PATCH] staging : lustre : Remove braces from single-line body. In-Reply-To: <1481911175-19592-1-git-send-email-khan.tabrez21@gmail.com> References: <1481911175-19592-1-git-send-email-khan.tabrez21@gmail.com> Message-ID: <1481913804.29291.92.camel@perches.com> On Fri, 2016-12-16 at 23:29 +0530, Tabrez khan wrote: > Remove unnecessary braces {} from single line if statement. > This warning is found using checkpatch.pl. [] > diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c [] > @@ -1134,9 +1134,9 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, > } > > /* Sanity checks for a reconnected import. */ > - if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) { > + if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) > CERROR("imp_replayable flag does not match server after reconnect. We should LBUG right here.\n"); > - } > + There are one too many blank lines now. And that's an awful lot of !s. Generically, it might make simpler reading code to cast to bool instead of using !. Most code uses !! to make sure whatever value is either 0 or 1 without changing the logic/polarity. From dan.carpenter at oracle.com Fri Dec 16 18:53:55 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Fri, 16 Dec 2016 21:53:55 +0300 Subject: [lustre-devel] [PATCH] staging : lustre : Remove braces from single-line body. In-Reply-To: <1481913804.29291.92.camel@perches.com> References: <1481911175-19592-1-git-send-email-khan.tabrez21@gmail.com> <1481913804.29291.92.camel@perches.com> Message-ID: <20161216185355.GH8176@mwanda> On Fri, Dec 16, 2016 at 10:43:24AM -0800, Joe Perches wrote: > On Fri, 2016-12-16 at 23:29 +0530, Tabrez khan wrote: > > Remove unnecessary braces {} from single line if statement. > > This warning is found using checkpatch.pl. > [] > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c > [] > > @@ -1134,9 +1134,9 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, > > } > > > > /* Sanity checks for a reconnected import. */ > > - if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) { > > + if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) > > CERROR("imp_replayable flag does not match server after reconnect. We should LBUG right here.\n"); > > - } > > + > > There are one too many blank lines now. I was expecting checkpatch.pl to catch the extra blank. It was there in the last patch as well. Apparently it doesn't. regards, dan carpenter From joe at perches.com Fri Dec 16 19:19:22 2016 From: joe at perches.com (Joe Perches) Date: Fri, 16 Dec 2016 11:19:22 -0800 Subject: [lustre-devel] [PATCH] staging : lustre : Remove braces from single-line body. In-Reply-To: <20161216185355.GH8176@mwanda> References: <1481911175-19592-1-git-send-email-khan.tabrez21@gmail.com> <1481913804.29291.92.camel@perches.com> <20161216185355.GH8176@mwanda> Message-ID: <1481915962.29291.96.camel@perches.com> On Fri, 2016-12-16 at 21:53 +0300, Dan Carpenter wrote: > On Fri, Dec 16, 2016 at 10:43:24AM -0800, Joe Perches wrote: > > On Fri, 2016-12-16 at 23:29 +0530, Tabrez khan wrote: > > > Remove unnecessary braces {} from single line if statement. > > > This warning is found using checkpatch.pl. > > > > [] > > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c > > > > [] > > > @@ -1134,9 +1134,9 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, > > > } > > > > > > /* Sanity checks for a reconnected import. */ > > > - if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) { > > > + if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) > > > CERROR("imp_replayable flag does not match server after reconnect. We should LBUG right here.\n"); > > > - } > > > + > > > > There are one too many blank lines now. > > I was expecting checkpatch.pl to catch the extra blank. It was there in > the last patch as well. Apparently it doesn't. checkpatch is imperfect and always will be. checkpatch is a stupid little script. It mostly works on added lines and generally only looks for style defects on lines that precede those added lines. Here the now unnecessary blank line follows the added blank line. Oh well. Anyway, here's an almost completely untested possible patch to checkpatch. (also attached because evolution is a terrible email client, but I seem to be stuck with it) --- scripts/checkpatch.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1579230ebacc..97078f7629e2 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3063,6 +3063,19 @@ sub process { $last_blank_line = $linenr; } +# Another check for multiple consecutive blank lines where the following +# line is part of the context and is also blank + if ($line =~ /^\+\s*$/ && + defined $rawlines[$linenr] && + $rawlines[$linenr] =~ /^ \s*$/) { + if (CHK("LINE_SPACING", + "Please don't use multiple blank lines\n" . $hereprev) && + $fix) { + fix_delete_line($fixlinenr, $rawline); + } + $last_blank_line = $linenr; + } + # check for missing blank lines after declarations if ($sline =~ /^\+\s+\S/ && #Not at char 1 # actual declarations -------------- next part -------------- A non-text attachment was scrubbed... Name: cp_trailing_context_blank.diff Type: text/x-patch Size: 860 bytes Desc: not available URL: From sandeepjain.linux at gmail.com Mon Dec 5 03:06:37 2016 From: sandeepjain.linux at gmail.com (sandeepjain.linux at gmail.com) Date: Mon, 5 Dec 2016 08:36:37 +0530 Subject: [lustre-devel] [PATCH] staging: lustre: Fix function declaration/definition mismatch Message-ID: <1480907197-23201-1-git-send-email-sandeepjain.linux@gmail.com> From: Sandeep Jain Fixes following Sparse errors. lprocfs_status.c:1568:5: error: symbol 'lprocfs_wr_root_squash' redeclared with different type... lprocfs_status.c:1632:5: error: symbol 'lprocfs_wr_nosquash_nids' redeclared with different type... Signed-off-by: Sandeep Jain --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index cc0713e..b5c24ca 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -701,9 +701,9 @@ static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store) extern const struct sysfs_ops lustre_sysfs_ops; struct root_squash_info; -int lprocfs_wr_root_squash(const char *buffer, unsigned long count, +int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count, struct root_squash_info *squash, char *name); -int lprocfs_wr_nosquash_nids(const char *buffer, unsigned long count, +int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count, struct root_squash_info *squash, char *name); /* all quota proc functions */ -- 2.7.4 From khan.tabrez21 at gmail.com Wed Dec 14 21:11:24 2016 From: khan.tabrez21 at gmail.com (Tabrez khan) Date: Thu, 15 Dec 2016 02:41:24 +0530 Subject: [lustre-devel] [PATCH] staging : osc : coding style fix Message-ID: <1481749884-25674-1-git-send-email-khan.tabrez21@gmail.com> Remove unnecessary braces {} for single if statement block. This warning is found using checkpatch.pl. Signed-off-by: Tabrez khan --- drivers/staging/lustre/lustre/osc/osc_cache.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 4bbe219..5ded31a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1420,10 +1420,8 @@ static void osc_release_write_grant(struct client_obd *cli, struct brw_page *pga) { assert_spin_locked(&cli->cl_loi_list_lock); - if (!(pga->flag & OBD_BRW_FROM_GRANT)) { + if (!(pga->flag & OBD_BRW_FROM_GRANT)) return; - } - pga->flag &= ~OBD_BRW_FROM_GRANT; atomic_long_dec(&obd_dirty_pages); cli->cl_dirty_pages--; -- 2.7.4 From hubcap at omnibond.com Tue Dec 6 18:52:14 2016 From: hubcap at omnibond.com (Mike Marshall) Date: Tue, 6 Dec 2016 13:52:14 -0500 Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: <606EDBC7-4555-42DD-85E7-66620E601C85@intel.com> References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> <20161203085550.GA5375@kroah.com> <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> <20161206161524.GA5535@kroah.com> <7AF464A9-1D0F-48E9-B83C-66F983268473@intel.com> <606EDBC7-4555-42DD-85E7-66620E601C85@intel.com> Message-ID: > Checkpatch still complains about this I believe. Yes. But if you leave the line longer than 80 characters, it complains about that too. I hoped that since the point was not to break grepability, it was better to make the code look nicer. This is the first chance I've had to say what I'd been doing when numerous senior developers were looking, if my method is worse than leaving the long lines, I'll quit doing it... -Mike On Tue, Dec 6, 2016 at 1:14 PM, Oleg Drokin wrote: > > On Dec 6, 2016, at 1:07 PM, Mike Marshall wrote: > >> > long error messages that we cannot split into a multiline thing anyway. >> >> I split numerous Orangefs ones at substitution characters, which >> didn't break grepability. No one complained, and sure made >> stuff look nicer to me. You might be able to do that some places? > > Checkpatch still complains about this I believe. > >> >> -Mike >> >> On Tue, Dec 6, 2016 at 12:50 PM, Oleg Drokin wrote: >> >> On Dec 6, 2016, at 11:15 AM, Greg KH wrote: >> >> > On Tue, Dec 06, 2016 at 10:34:03AM -0500, Oleg Drokin wrote: >> >> >> >> On Dec 3, 2016, at 3:55 AM, gregkh at linuxfoundation.org wrote: >> >> >> >>> On Fri, Dec 02, 2016 at 09:53:08PM +0000, Dilger, Andreas wrote: >> >>>> Al, >> >>>> Greg recently raised the issue of what still needs to be done to >> >>>> move the Lustre code out of staging/ and into the fs/ tree. >> >>>> >> >>>> James has been doing a great job of cleaning up various checkpatch >> >>>> issues and keeping the code updated with the latest fixes, but we >> >>>> were wondering what you were aware of that needed to be cleaned >> >>>> up in Lustre? >> >>> >> >>> Is the whole "mixing kernel structures in userspace structures" all >> >>> resolved now? For some reason I thought that you had kernel locks being >> >>> passed to userspace and then back into the kernel, but it's been a long >> >>> time since I last looked... >> >> >> >> While we certainly had our share of mixing user/kernelspace structures, >> >> I don't think we ever passed anything with locks around back and forth. >> >> >> >> I just did a brief check and I don't see anything glaring on this particular front. >> >> >> >>> If you feel you are ready for a "real" review, I'll be glad to go over >> >>> the code before the vfs people look at it, just let me know. No need to >> >>> bother them if you still have basic things wrong that I can find… >> >> >> >> I think this would be beneficial at this stage. >> > >> > I see loads of checkpatch.pl warnings and a few errors, how about fixing >> > all of them up first? >> > >> >> There are 16 errors, >> of them: >> 8 are false positives in drivers/staging/lustre/lnet/libcfs/hash.c >> 1 false positive in drivers/staging/lustre/lnet/libcfs/tracefile.h >> 1 false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h >> 1 I think false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h (PLDLMRES) >> 2 false positives in drivers/staging/lustre/lustre/include/lustre/lustre_user.h >> >> an error I don't really understand, what does it want us to do here? >> ERROR: trailing statements should be on next line >> #196951: FILE: drivers/staging/lustre/lustre/mdc/mdc_request.c:1063: >> + for (end_dirent = ent; ent; >> + end_dirent = ent, ent = lu_dirent_next(ent)); >> >> leaving 2 real ones, one missing space in drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c >> and 1 spaces instead of tabs in drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h >> >> I'll have patches shortly for these. >> >> On the warning front, we have 879 line over 80 characters, but a bunch >> of those are due to long error messages that we cannot split into a multiline thing anyway. >> 71 Prefer 'unsigned int' to bare use of 'unsigned' that is a relatively new one >> 22 new typedefs (all in lnet, I drove out all the lustre ones, so I guess I can tackle these too). >> a bunch of comment style problems >> a few "function definition argument … should also have an identifier name" that >> seems to be a new one too, I don't remember seeing this before. >> >> And a bunch of rarer ones for the total of 1243 (823 in just Lustre). >> Multiple classes of them are actually not easily fixable or false positives too. >> Do you really want all of these fixed too somehow? >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in >> the body of a message to majordomo at vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> > From khan.tabrez21 at gmail.com Fri Dec 16 14:29:31 2016 From: khan.tabrez21 at gmail.com (Tabrez khan) Date: Fri, 16 Dec 2016 19:59:31 +0530 Subject: [lustre-devel] [PATCH] staging : lustre : Remove braces from single-line body. Message-ID: <1481898571-16842-1-git-send-email-khan.tabrez21@gmail.com> Remove unnecessary braces {} for single while statement. This warning is found using checkpatch.pl. Signed-off-by: Tabrez khan --- drivers/staging/lustre/lustre/obdclass/cl_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index bc4b7b6..2daede8 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -1371,9 +1371,9 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, LASSERT(atomic_read(&anchor->csi_sync_nr) == 0); /* wait until cl_sync_io_note() has done wakeup */ - while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) { + while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) cpu_relax(); - } + return rc; } -- 2.7.4 From bigeasy at linutronix.de Fri Dec 2 10:18:25 2016 From: bigeasy at linutronix.de (Sebastian Andrzej Siewior) Date: Fri, 2 Dec 2016 11:18:25 +0100 Subject: [lustre-devel] [PATCH 21/22 v2] staging/lustre/libcfs: Convert to hotplug state machine In-Reply-To: <20161126231350.10321-22-bigeasy@linutronix.de> References: <20161126231350.10321-1-bigeasy@linutronix.de> <20161126231350.10321-22-bigeasy@linutronix.de> Message-ID: <20161202101825.mcsbw4nr4slymcvl@linutronix.de> From: Anna-Maria Gleixner Install the callbacks via the state machine. Cc: Oleg Drokin Cc: Andreas Dilger Cc: James Simmons Cc: Greg Kroah-Hartman Cc: lustre-devel at lists.lustre.org Cc: devel at driverdev.osuosl.org Signed-off-by: Anna-Maria Gleixner [bigeasy: rebase to linux-next] Signed-off-by: Sebastian Andrzej Siewior --- v1…v2: rebase to linux-next Side note: Is there a reason the handle the down state very late at CPU_DEAD time and use the counterpart of the online callback (the old CPU_DOWN_PREPARE state). .../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 88 ++++++++++++---------- include/linux/cpuhotplug.h | 1 + 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c index 6b9cf06e8df2..f70b7d16378c 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c @@ -75,6 +75,9 @@ struct cfs_cpt_data { }; static struct cfs_cpt_data cpt_data; +#ifdef CONFIG_HOTPLUG_CPU +static enum cpuhp_state lustre_cpu_online; +#endif static void cfs_node_to_cpumask(int node, cpumask_t *mask) @@ -967,48 +970,37 @@ cfs_cpt_table_create_pattern(char *pattern) } #ifdef CONFIG_HOTPLUG_CPU -static int -cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) +static void cfs_cpu_incr_cpt_version(void) { - unsigned int cpu = (unsigned long)hcpu; - bool warn; - - switch (action) { - case CPU_DEAD: - case CPU_DEAD_FROZEN: - case CPU_ONLINE: - case CPU_ONLINE_FROZEN: - spin_lock(&cpt_data.cpt_lock); - cpt_data.cpt_version++; - spin_unlock(&cpt_data.cpt_lock); - /* Fall through */ - default: - if (action != CPU_DEAD && action != CPU_DEAD_FROZEN) { - CDEBUG(D_INFO, "CPU changed [cpu %u action %lx]\n", - cpu, action); - break; - } - - mutex_lock(&cpt_data.cpt_mutex); - /* if all HTs in a core are offline, it may break affinity */ - cpumask_copy(cpt_data.cpt_cpumask, - topology_sibling_cpumask(cpu)); - warn = cpumask_any_and(cpt_data.cpt_cpumask, - cpu_online_mask) >= nr_cpu_ids; - mutex_unlock(&cpt_data.cpt_mutex); - CDEBUG(warn ? D_WARNING : D_INFO, - "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u action: %lx]\n", - cpu, action); - } - - return NOTIFY_OK; + spin_lock(&cpt_data.cpt_lock); + cpt_data.cpt_version++; + spin_unlock(&cpt_data.cpt_lock); } -static struct notifier_block cfs_cpu_notifier = { - .notifier_call = cfs_cpu_notify, - .priority = 0 -}; +static int cfs_cpu_online(unsigned int cpu) +{ + cfs_cpu_incr_cpt_version(); + return 0; +} +static int cfs_cpu_dead(unsigned int cpu) +{ + bool warn; + + cfs_cpu_incr_cpt_version(); + + mutex_lock(&cpt_data.cpt_mutex); + /* if all HTs in a core are offline, it may break affinity */ + cpumask_copy(cpt_data.cpt_cpumask, + topology_sibling_cpumask(cpu)); + warn = cpumask_any_and(cpt_data.cpt_cpumask, + cpu_online_mask) >= nr_cpu_ids; + mutex_unlock(&cpt_data.cpt_mutex); + CDEBUG(warn ? D_WARNING : D_INFO, + "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u]\n", + cpu); + return 0; +} #endif void @@ -1018,7 +1010,9 @@ cfs_cpu_fini(void) cfs_cpt_table_free(cfs_cpt_table); #ifdef CONFIG_HOTPLUG_CPU - unregister_hotcpu_notifier(&cfs_cpu_notifier); + if (lustre_cpu_online) + cpuhp_remove_state_nocalls(lustre_cpu_online); + cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD); #endif if (cpt_data.cpt_cpumask) LIBCFS_FREE(cpt_data.cpt_cpumask, cpumask_size()); @@ -1027,6 +1021,10 @@ cfs_cpu_fini(void) int cfs_cpu_init(void) { +#ifdef CONFIG_HOTPLUG_CPU + int ret; +#endif + LASSERT(!cfs_cpt_table); memset(&cpt_data, 0, sizeof(cpt_data)); @@ -1041,7 +1039,17 @@ cfs_cpu_init(void) mutex_init(&cpt_data.cpt_mutex); #ifdef CONFIG_HOTPLUG_CPU - register_hotcpu_notifier(&cfs_cpu_notifier); + ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD, + "staging/lustre/cfe:dead", NULL, + cfs_cpu_dead); + if (ret < 0) + goto failed; + ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, + "staging/lustre/cfe:online", + cfs_cpu_online, NULL); + if (ret < 0) + goto failed; + lustre_cpu_online = ret; #endif if (*cpu_pattern) { diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 22acee76cf4c..141c3be242d1 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -41,6 +41,7 @@ enum cpuhp_state { CPUHP_NET_DEV_DEAD, CPUHP_PCI_XGENE_DEAD, CPUHP_IOMMU_INTEL_DEAD, + CPUHP_LUSTRE_CFS_DEAD, CPUHP_WORKQUEUE_PREP, CPUHP_POWER_NUMA_PREPARE, CPUHP_HRTIMERS_PREPARE, -- 2.10.2 From hubcap at omnibond.com Tue Dec 6 18:07:40 2016 From: hubcap at omnibond.com (Mike Marshall) Date: Tue, 6 Dec 2016 13:07:40 -0500 Subject: [lustre-devel] Remaining work needed for moving Lustre out of staging In-Reply-To: <7AF464A9-1D0F-48E9-B83C-66F983268473@intel.com> References: <1E1B324A-F545-417D-9C35-550FA58665C7@intel.com> <20161203085550.GA5375@kroah.com> <0F617FFB-4BD0-4477-890B-2CDC56436DCC@intel.com> <20161206161524.GA5535@kroah.com> <7AF464A9-1D0F-48E9-B83C-66F983268473@intel.com> Message-ID: > long error messages that we cannot split into a multiline thing anyway. I split numerous Orangefs ones at substitution characters, which didn't break grepability. No one complained, and sure made stuff look nicer to me. You might be able to do that some places? -Mike On Tue, Dec 6, 2016 at 12:50 PM, Oleg Drokin wrote: > > On Dec 6, 2016, at 11:15 AM, Greg KH wrote: > > > On Tue, Dec 06, 2016 at 10:34:03AM -0500, Oleg Drokin wrote: > >> > >> On Dec 3, 2016, at 3:55 AM, gregkh at linuxfoundation.org wrote: > >> > >>> On Fri, Dec 02, 2016 at 09:53:08PM +0000, Dilger, Andreas wrote: > >>>> Al, > >>>> Greg recently raised the issue of what still needs to be done to > >>>> move the Lustre code out of staging/ and into the fs/ tree. > >>>> > >>>> James has been doing a great job of cleaning up various checkpatch > >>>> issues and keeping the code updated with the latest fixes, but we > >>>> were wondering what you were aware of that needed to be cleaned > >>>> up in Lustre? > >>> > >>> Is the whole "mixing kernel structures in userspace structures" all > >>> resolved now? For some reason I thought that you had kernel locks > being > >>> passed to userspace and then back into the kernel, but it's been a long > >>> time since I last looked... > >> > >> While we certainly had our share of mixing user/kernelspace structures, > >> I don't think we ever passed anything with locks around back and forth. > >> > >> I just did a brief check and I don't see anything glaring on this > particular front. > >> > >>> If you feel you are ready for a "real" review, I'll be glad to go over > >>> the code before the vfs people look at it, just let me know. No need > to > >>> bother them if you still have basic things wrong that I can find… > >> > >> I think this would be beneficial at this stage. > > > > I see loads of checkpatch.pl warnings and a few errors, how about fixing > > all of them up first? > > > > There are 16 errors, > of them: > 8 are false positives in drivers/staging/lustre/lnet/libcfs/hash.c > 1 false positive in drivers/staging/lustre/lnet/libcfs/tracefile.h > 1 false positive in drivers/staging/lustre/lustre/ > include/lustre/lustre_idl.h > 1 I think false positive in drivers/staging/lustre/lustre/include/lustre/lustre_idl.h > (PLDLMRES) > 2 false positives in drivers/staging/lustre/lustre/ > include/lustre/lustre_user.h > > an error I don't really understand, what does it want us to do here? > ERROR: trailing statements should be on next line > #196951: FILE: drivers/staging/lustre/lustre/mdc/mdc_request.c:1063: > + for (end_dirent = ent; ent; > + end_dirent = ent, ent = lu_dirent_next(ent)); > > leaving 2 real ones, one missing space in drivers/staging/lustre/lnet/ > klnds/o2iblnd/o2iblnd_cb.c > and 1 spaces instead of tabs in drivers/staging/lustre/lnet/ > klnds/socklnd/socklnd.h > > I'll have patches shortly for these. > > On the warning front, we have 879 line over 80 characters, but a bunch > of those are due to long error messages that we cannot split into a > multiline thing anyway. > 71 Prefer 'unsigned int' to bare use of 'unsigned' that is a relatively > new one > 22 new typedefs (all in lnet, I drove out all the lustre ones, so I guess > I can tackle these too). > a bunch of comment style problems > a few "function definition argument … should also have an identifier name" > that > seems to be a new one too, I don't remember seeing this before. > > And a bunch of rarer ones for the total of 1243 (823 in just Lustre). > Multiple classes of them are actually not easily fixable or false > positives too. > Do you really want all of these fixed too somehow? > > -- > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo at vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bigeasy at linutronix.de Fri Dec 2 11:00:28 2016 From: bigeasy at linutronix.de (Sebastian Andrzej Siewior) Date: Fri, 2 Dec 2016 12:00:28 +0100 Subject: [lustre-devel] [PATCH 21/22 v3] staging/lustre/libcfs: Convert to hotplug state machine In-Reply-To: <20161202104244.GB8736@kroah.com> References: <20161126231350.10321-1-bigeasy@linutronix.de> <20161126231350.10321-22-bigeasy@linutronix.de> <20161202101825.mcsbw4nr4slymcvl@linutronix.de> <20161202104244.GB8736@kroah.com> Message-ID: <20161202110027.htzzeervzkoc4muv@linutronix.de> From: Anna-Maria Gleixner Install the callbacks via the state machine. Cc: Oleg Drokin Cc: Andreas Dilger Cc: James Simmons Cc: Greg Kroah-Hartman Cc: lustre-devel at lists.lustre.org Cc: devel at driverdev.osuosl.org Signed-off-by: Anna-Maria Gleixner [bigeasy: rebase to linux-next] Signed-off-by: Sebastian Andrzej Siewior --- v2…v3: add the missing blank before the Cc: lines. v1…v2: rebase to linux-next Side note: Is there a reason the handle the down state very late at CPU_DEAD time and use the counterpart of the online callback (the old CPU_DOWN_PREPARE state). .../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 88 ++++++++++++---------- include/linux/cpuhotplug.h | 1 + 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c index 6b9cf06e8df2..f70b7d16378c 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c @@ -75,6 +75,9 @@ struct cfs_cpt_data { }; static struct cfs_cpt_data cpt_data; +#ifdef CONFIG_HOTPLUG_CPU +static enum cpuhp_state lustre_cpu_online; +#endif static void cfs_node_to_cpumask(int node, cpumask_t *mask) @@ -967,48 +970,37 @@ cfs_cpt_table_create_pattern(char *pattern) } #ifdef CONFIG_HOTPLUG_CPU -static int -cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) +static void cfs_cpu_incr_cpt_version(void) { - unsigned int cpu = (unsigned long)hcpu; - bool warn; - - switch (action) { - case CPU_DEAD: - case CPU_DEAD_FROZEN: - case CPU_ONLINE: - case CPU_ONLINE_FROZEN: - spin_lock(&cpt_data.cpt_lock); - cpt_data.cpt_version++; - spin_unlock(&cpt_data.cpt_lock); - /* Fall through */ - default: - if (action != CPU_DEAD && action != CPU_DEAD_FROZEN) { - CDEBUG(D_INFO, "CPU changed [cpu %u action %lx]\n", - cpu, action); - break; - } - - mutex_lock(&cpt_data.cpt_mutex); - /* if all HTs in a core are offline, it may break affinity */ - cpumask_copy(cpt_data.cpt_cpumask, - topology_sibling_cpumask(cpu)); - warn = cpumask_any_and(cpt_data.cpt_cpumask, - cpu_online_mask) >= nr_cpu_ids; - mutex_unlock(&cpt_data.cpt_mutex); - CDEBUG(warn ? D_WARNING : D_INFO, - "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u action: %lx]\n", - cpu, action); - } - - return NOTIFY_OK; + spin_lock(&cpt_data.cpt_lock); + cpt_data.cpt_version++; + spin_unlock(&cpt_data.cpt_lock); } -static struct notifier_block cfs_cpu_notifier = { - .notifier_call = cfs_cpu_notify, - .priority = 0 -}; +static int cfs_cpu_online(unsigned int cpu) +{ + cfs_cpu_incr_cpt_version(); + return 0; +} +static int cfs_cpu_dead(unsigned int cpu) +{ + bool warn; + + cfs_cpu_incr_cpt_version(); + + mutex_lock(&cpt_data.cpt_mutex); + /* if all HTs in a core are offline, it may break affinity */ + cpumask_copy(cpt_data.cpt_cpumask, + topology_sibling_cpumask(cpu)); + warn = cpumask_any_and(cpt_data.cpt_cpumask, + cpu_online_mask) >= nr_cpu_ids; + mutex_unlock(&cpt_data.cpt_mutex); + CDEBUG(warn ? D_WARNING : D_INFO, + "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u]\n", + cpu); + return 0; +} #endif void @@ -1018,7 +1010,9 @@ cfs_cpu_fini(void) cfs_cpt_table_free(cfs_cpt_table); #ifdef CONFIG_HOTPLUG_CPU - unregister_hotcpu_notifier(&cfs_cpu_notifier); + if (lustre_cpu_online) + cpuhp_remove_state_nocalls(lustre_cpu_online); + cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD); #endif if (cpt_data.cpt_cpumask) LIBCFS_FREE(cpt_data.cpt_cpumask, cpumask_size()); @@ -1027,6 +1021,10 @@ cfs_cpu_fini(void) int cfs_cpu_init(void) { +#ifdef CONFIG_HOTPLUG_CPU + int ret; +#endif + LASSERT(!cfs_cpt_table); memset(&cpt_data, 0, sizeof(cpt_data)); @@ -1041,7 +1039,17 @@ cfs_cpu_init(void) mutex_init(&cpt_data.cpt_mutex); #ifdef CONFIG_HOTPLUG_CPU - register_hotcpu_notifier(&cfs_cpu_notifier); + ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD, + "staging/lustre/cfe:dead", NULL, + cfs_cpu_dead); + if (ret < 0) + goto failed; + ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, + "staging/lustre/cfe:online", + cfs_cpu_online, NULL); + if (ret < 0) + goto failed; + lustre_cpu_online = ret; #endif if (*cpu_pattern) { diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 22acee76cf4c..141c3be242d1 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -41,6 +41,7 @@ enum cpuhp_state { CPUHP_NET_DEV_DEAD, CPUHP_PCI_XGENE_DEAD, CPUHP_IOMMU_INTEL_DEAD, + CPUHP_LUSTRE_CFS_DEAD, CPUHP_WORKQUEUE_PREP, CPUHP_POWER_NUMA_PREPARE, CPUHP_HRTIMERS_PREPARE, -- 2.10.2 From keescook at chromium.org Sat Dec 17 01:00:45 2016 From: keescook at chromium.org (Kees Cook) Date: Fri, 16 Dec 2016 17:00:45 -0800 Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers Message-ID: <20161217010045.GA140343@beast> Prepare to mark sensitive kernel structures for randomization by making sure they're using designated initializers. These were identified during allyesconfig builds of x86, arm, and arm64, with most initializer fixes extracted from grsecurity. Signed-off-by: Kees Cook --- drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index 722160784f83..f815827532dc 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int added = (mode == LCK_NL); int overlaps = 0; int splitted = 0; - const struct ldlm_callback_suite null_cbs = { NULL }; + const struct ldlm_callback_suite null_cbs = { }; CDEBUG(D_DLMTRACE, "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", -- 2.7.4 -- Kees Cook Nexus Security From bianpan201602 at 163.com Sat Dec 3 12:52:55 2016 From: bianpan201602 at 163.com (Pan Bian) Date: Sat, 3 Dec 2016 20:52:55 +0800 Subject: [lustre-devel] [PATCH 1/1] staging: lustre: lnet: fix improper return value Message-ID: <1480769575-6074-1-git-send-email-bianpan201602@163.com> From: Pan Bian At the end of function lstcon_group_info(), "return 0" seems improper. It may be better to return the value of rc. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188811 Signed-off-by: Pan Bian --- drivers/staging/lustre/lnet/selftest/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index a0fcbf3..9a7c41a 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -820,7 +820,7 @@ lstcon_group_decref(grp); - return 0; + return rc; } static int -- 1.9.1 From khan.tabrez21 at gmail.com Thu Dec 15 01:33:52 2016 From: khan.tabrez21 at gmail.com (Tabrez khan) Date: Thu, 15 Dec 2016 07:03:52 +0530 Subject: [lustre-devel] [PATCH] staging : osc : Remove braces from single-line body Message-ID: <1481765632-29876-1-git-send-email-khan.tabrez21@gmail.com> Remove unnecessary braces {} for single if statement block. This warning is found using checkpatch.pl. Signed-off-by: Tabrez khan --- drivers/staging/lustre/lustre/osc/osc_cache.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 4bbe219..5ded31a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1420,10 +1420,8 @@ static void osc_release_write_grant(struct client_obd *cli, struct brw_page *pga) { assert_spin_locked(&cli->cl_loi_list_lock); - if (!(pga->flag & OBD_BRW_FROM_GRANT)) { + if (!(pga->flag & OBD_BRW_FROM_GRANT)) return; - } - pga->flag &= ~OBD_BRW_FROM_GRANT; atomic_long_dec(&obd_dirty_pages); cli->cl_dirty_pages--; -- 2.7.4 From sandeepjain.linux at gmail.com Mon Dec 5 02:21:21 2016 From: sandeepjain.linux at gmail.com (sandeepjain.linux at gmail.com) Date: Mon, 5 Dec 2016 07:51:21 +0530 Subject: [lustre-devel] [PATCH] staging: lustre: mgc: make llog_process_lock static Message-ID: <1480904481-20149-1-git-send-email-sandeepjain.linux@gmail.com> From: Sandeep Jain Fix following sparse warning. mgc_request.c:376:1: warning: symbol 'llog_process_lock' was not declared. Should it be static? Signed-off-by: Sandeep Jain --- drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 23600fb..e98a2ce 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -373,7 +373,7 @@ static int config_log_add(struct obd_device *obd, char *logname, return rc; } -DEFINE_MUTEX(llog_process_lock); +static DEFINE_MUTEX(llog_process_lock); /** Stop watching for updates on this log. */ -- 2.7.4 From khan.tabrez21 at gmail.com Fri Dec 16 17:59:35 2016 From: khan.tabrez21 at gmail.com (Tabrez khan) Date: Fri, 16 Dec 2016 23:29:35 +0530 Subject: [lustre-devel] [PATCH] staging : lustre : Remove braces from single-line body. Message-ID: <1481911175-19592-1-git-send-email-khan.tabrez21@gmail.com> Remove unnecessary braces {} from single line if statement. This warning is found using checkpatch.pl. Signed-off-by: Tabrez khan --- drivers/staging/lustre/lustre/ptlrpc/import.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index a23d0a0..477d832 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -1134,9 +1134,9 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, } /* Sanity checks for a reconnected import. */ - if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) { + if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) CERROR("imp_replayable flag does not match server after reconnect. We should LBUG right here.\n"); - } + if (lustre_msg_get_last_committed(request->rq_repmsg) > 0 && lustre_msg_get_last_committed(request->rq_repmsg) < -- 2.7.4 From khan.tabrez21 at gmail.com Thu Dec 15 14:39:16 2016 From: khan.tabrez21 at gmail.com (Tabrez Khan) Date: Thu, 15 Dec 2016 20:09:16 +0530 Subject: [lustre-devel] [PATCH] staging : osc : Remove braces from single-line body In-Reply-To: <20161215013834.GA7055@kroah.com> References: <1481765632-29876-1-git-send-email-khan.tabrez21@gmail.com> <20161215013834.GA7055@kroah.com> Message-ID: On Thu, Dec 15, 2016 at 7:08 AM, Greg KH wrote: > On Thu, Dec 15, 2016 at 07:03:52AM +0530, Tabrez khan wrote: >> Remove unnecessary braces {} for single if statement block. >> This warning is found using checkpatch.pl. >> >> Signed-off-by: Tabrez khan >> --- >> drivers/staging/lustre/lustre/osc/osc_cache.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c >> index 4bbe219..5ded31a 100644 >> --- a/drivers/staging/lustre/lustre/osc/osc_cache.c >> +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c >> @@ -1420,10 +1420,8 @@ static void osc_release_write_grant(struct client_obd *cli, >> struct brw_page *pga) >> { >> assert_spin_locked(&cli->cl_loi_list_lock); >> - if (!(pga->flag & OBD_BRW_FROM_GRANT)) { >> + if (!(pga->flag & OBD_BRW_FROM_GRANT)) >> return; >> - } >> - > > Why did you also delete the blank line? Because to keep the kernel coding style as close as possible and after deleting brace it leads to extra empty line so i delete it. Please guide if done something wrong. From jsimmons at infradead.org Mon Dec 19 16:22:58 2016 From: jsimmons at infradead.org (James Simmons) Date: Mon, 19 Dec 2016 16:22:58 +0000 (GMT) Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: <20161217010045.GA140343@beast> References: <20161217010045.GA140343@beast> Message-ID: > Prepare to mark sensitive kernel structures for randomization by making > sure they're using designated initializers. These were identified during > allyesconfig builds of x86, arm, and arm64, with most initializer fixes > extracted from grsecurity. > > Signed-off-by: Kees Cook > --- > drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > index 722160784f83..f815827532dc 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, > int added = (mode == LCK_NL); > int overlaps = 0; > int splitted = 0; > - const struct ldlm_callback_suite null_cbs = { NULL }; > + const struct ldlm_callback_suite null_cbs = { }; > > CDEBUG(D_DLMTRACE, > "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", Nak. Filling null_cbs with random data is a bad idea. If you look at ldlm_lock_create() where this is used you have if (cbs) { lock->l_blocking_ast = cbs->lcs_blocking; lock->l_completion_ast = cbs->lcs_completion; lock->l_glimpse_ast = cbs->lcs_glimpse; } Having lock->l_* point to random addresses is a bad idea. What really needs to be done is proper initialization of that structure. A bunch of patches will be coming to address this. From jsimmons at infradead.org Mon Dec 19 16:38:44 2016 From: jsimmons at infradead.org (James Simmons) Date: Mon, 19 Dec 2016 16:38:44 +0000 (GMT) Subject: [lustre-devel] [PATCH v2] staging: lustre: Fix variable type declaration after refactoring In-Reply-To: <20161208203827.20561-1-lambert.quentin@gmail.com> References: <20161208203827.20561-1-lambert.quentin@gmail.com> Message-ID: > A recent clean-up declared och_flags as a int rather than fmode_t. This > lead to the following sparse warning: > > drivers/staging/lustre/lustre/llite/file.c:106:30: warning: restricted > fmode_t degrades to integer > > This patch fixes this issue. Acked-by: James Simmons > Fixes: 0a1200991234f7 ("staging: lustre: cleanup lustre_lib.h") > Signed-off-by: Quentin Lambert > --- > v2: fixes the referenced sha > > drivers/staging/lustre/lustre/include/obd.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > --- a/drivers/staging/lustre/lustre/include/obd.h > +++ b/drivers/staging/lustre/lustre/include/obd.h > @@ -889,7 +889,7 @@ struct obd_client_handle { > struct md_open_data *och_mod; > struct lustre_handle och_lease_handle; /* open lock for lease */ > __u32 och_magic; > - int och_flags; > + fmode_t och_flags; > }; > > #define OBD_CLIENT_HANDLE_MAGIC 0xd15ea5ed > From paf at cray.com Mon Dec 19 16:50:02 2016 From: paf at cray.com (Patrick Farrell) Date: Mon, 19 Dec 2016 16:50:02 +0000 Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: References: <20161217010045.GA140343@beast>, Message-ID: James, This should be a purely syntactical change, to help out tools - for GCC, I'm pretty sure the meaning of { } and { NULL } are the same. Also, I don't think struct randomization does what you're thinking. Kees, Is there anything written up on kernel struct randomization? I was trying to find a talk/post from you or something from LWN, but I couldn't find something about this specifically. (Probably because I can't find it among the other stuff that's been written up) - Patrick ________________________________ From: lustre-devel on behalf of James Simmons Sent: Monday, December 19, 2016 10:22:58 AM To: Kees Cook Cc: devel at driverdev.osuosl.org; Greg Kroah-Hartman; linux-kernel at vger.kernel.org; Oleg Drokin; Vitaly Fertman; Bruce Korb; Emoly Liu; lustre-devel at lists.lustre.org Subject: Re: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers > Prepare to mark sensitive kernel structures for randomization by making > sure they're using designated initializers. These were identified during > allyesconfig builds of x86, arm, and arm64, with most initializer fixes > extracted from grsecurity. > > Signed-off-by: Kees Cook > --- > drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > index 722160784f83..f815827532dc 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, > int added = (mode == LCK_NL); > int overlaps = 0; > int splitted = 0; > - const struct ldlm_callback_suite null_cbs = { NULL }; > + const struct ldlm_callback_suite null_cbs = { }; > > CDEBUG(D_DLMTRACE, > "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", Nak. Filling null_cbs with random data is a bad idea. If you look at ldlm_lock_create() where this is used you have if (cbs) { lock->l_blocking_ast = cbs->lcs_blocking; lock->l_completion_ast = cbs->lcs_completion; lock->l_glimpse_ast = cbs->lcs_glimpse; } Having lock->l_* point to random addresses is a bad idea. What really needs to be done is proper initialization of that structure. A bunch of patches will be coming to address this. _______________________________________________ lustre-devel mailing list lustre-devel at lists.lustre.org http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From jsimmons at infradead.org Mon Dec 19 17:02:43 2016 From: jsimmons at infradead.org (James Simmons) Date: Mon, 19 Dec 2016 17:02:43 +0000 (GMT) Subject: [lustre-devel] [PATCH v2 5/5] staging: lustre: headers: use proper byteorder functions in lustre_idl.h In-Reply-To: <20161213010700.GA21619@kroah.com> References: <1481393161-22623-1-git-send-email-jsimmons@infradead.org> <1481393161-22623-6-git-send-email-jsimmons@infradead.org> <20161210181649.GB8477@kroah.com> <73FD0668-EDE9-4757-98ED-8A15CE5DA17C@intel.com> <20161213010700.GA21619@kroah.com> Message-ID: > On Tue, Dec 13, 2016 at 12:55:01AM +0000, Dilger, Andreas wrote: > > On Dec 12, 2016, at 13:00, James Simmons wrote: > > > > > > > > >> On Sat, Dec 10, 2016 at 01:06:01PM -0500, James Simmons wrote: > > >>> In order for lustre_idl.h to be usable for both user > > >>> land and kernel space it has to use the proper > > >>> byteorder functions. > > >> > > >> Why would userspace need/want all of these inline functions? A uapi > > >> header file should just have a the structures that are passed > > >> user/kernel and any needed ioctls. Why would they ever care about > > >> strange byte flip functions and a ton of inline functions? > > >> > > >> I don't think this is needed, of if it is, I really don't want to see > > >> your crazy userspace code... > > > > > > Sigh. More cleanups were done based on the idea this was okay. The > > > reason this was does was when you look at the headers in > > > include/uapi/linux you see a huge number of headers containing a bunch > > > of inline function. To an outside project looking to merge their work > > > into the kernel they would think this is okay. Hopefully all those > > > broken headers will be cleaned up in the near future. > > > Alright I will look to fixing up our tools to handle this requirement. > > > > These accessor functions are used by both the kernel and userspace > > tools, and keeping them in the lustre_idl.h header avoids duplication > > of code. Similar usage exists in other filesystem related uapi headers > > (e.g. auto_fs4.h, bcache.h, btrfs_tree.h, nilfs2_ondisk.h, swab.h, etc.). > > > > That said, if there is an objection to keeping these macros/inline funcs > > in the uapi headers, they still need to exist in the kernel and should > > be kept in the lustre/include/lustre directory and we'll keep a separate > > copy of the macros for userspace. > > "simple" accessors/setters are fine, but these start to get complex, you > are using unlikely, and debug macros and lots of other fun stuff. Do > all other filesystems also do complex stuff like ostid_to_fid()? So the rejection of the byteorder patch was more due to the state of headers than the patch itself. I do have other patches with the cleanup of debugging macros etc but I was submitting the change one change at a time. I will post what cleanups I was looking to do for lustre_ostid.h and lustre_fid.h UAPI headers. This way you can give feedback on what is okay and what has to change. From jsimmons at infradead.org Mon Dec 19 17:06:47 2016 From: jsimmons at infradead.org (James Simmons) Date: Mon, 19 Dec 2016 12:06:47 -0500 Subject: [lustre-devel] [PATCH] staging: lustre: headers: potential UAPI headers Message-ID: <1482167207-22800-1-git-send-email-jsimmons@infradead.org> Not for landing. This is the purposed UAPI headers with the removal of unlikely and debugging macros. This is just for feedback to see if this is acceptable for the upstream client. Signed-off-by: James Simmons --- .../lustre/lustre/include/lustre/lustre_fid.h | 353 +++++++++++++++++++++ .../lustre/lustre/include/lustre/lustre_ostid.h | 233 ++++++++++++++ 2 files changed, 586 insertions(+) create mode 100644 drivers/staging/lustre/lustre/include/lustre/lustre_fid.h create mode 100644 drivers/staging/lustre/lustre/include/lustre/lustre_ostid.h diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre/lustre_fid.h new file mode 100644 index 0000000..cb6afa5 --- /dev/null +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_fid.h @@ -0,0 +1,353 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2014, Intel Corporation. + * + * Copyright 2016 Cray Inc, all rights reserved. + * Author: Ben Evans. + * + * all fid manipulation functions go here + * + * FIDS are globally unique within a Lustre filessytem, and are made up + * of three parts: sequence, Object ID, and version. + * + */ +#ifndef _LUSTRE_LUSTRE_FID_H_ +#define _LUSTRE_LUSTRE_FID_H_ + +#include + +/** returns fid object sequence */ +static inline __u64 fid_seq(const struct lu_fid *fid) +{ + return fid->f_seq; +} + +/** returns fid object id */ +static inline __u32 fid_oid(const struct lu_fid *fid) +{ + return fid->f_oid; +} + +/** returns fid object version */ +static inline __u32 fid_ver(const struct lu_fid *fid) +{ + return fid->f_ver; +} + +static inline void fid_zero(struct lu_fid *fid) +{ + memset(fid, 0, sizeof(*fid)); +} + +static inline __u64 fid_ver_oid(const struct lu_fid *fid) +{ + return (__u64)fid_ver(fid) << 32 | fid_oid(fid); +} + +static inline bool fid_seq_is_mdt0(__u64 seq) +{ + return seq == FID_SEQ_OST_MDT0; +} + +static inline bool fid_seq_is_mdt(__u64 seq) +{ + return seq == FID_SEQ_OST_MDT0 || seq >= FID_SEQ_NORMAL; +}; + +static inline bool fid_seq_is_echo(__u64 seq) +{ + return seq == FID_SEQ_ECHO; +} + +static inline bool fid_is_echo(const struct lu_fid *fid) +{ + return fid_seq_is_echo(fid_seq(fid)); +} + +static inline bool fid_seq_is_llog(__u64 seq) +{ + return seq == FID_SEQ_LLOG; +} + +static inline bool fid_is_llog(const struct lu_fid *fid) +{ + /* file with OID == 0 is not llog but contains last oid */ + return fid_seq_is_llog(fid_seq(fid)) && fid_oid(fid) > 0; +} + +static inline bool fid_seq_is_rsvd(__u64 seq) +{ + return seq > FID_SEQ_OST_MDT0 && seq <= FID_SEQ_RSVD; +}; + +static inline bool fid_seq_is_special(__u64 seq) +{ + return seq == FID_SEQ_SPECIAL; +}; + +static inline bool fid_seq_is_local_file(__u64 seq) +{ + return seq == FID_SEQ_LOCAL_FILE || + seq == FID_SEQ_LOCAL_NAME; +}; + +static inline bool fid_seq_is_root(__u64 seq) +{ + return seq == FID_SEQ_ROOT; +} + +static inline bool fid_seq_is_dot(__u64 seq) +{ + return seq == FID_SEQ_DOT_LUSTRE; +} + +static inline bool fid_seq_is_default(__u64 seq) +{ + return seq == FID_SEQ_LOV_DEFAULT; +} + +static inline bool fid_is_mdt0(const struct lu_fid *fid) +{ + return fid_seq_is_mdt0(fid_seq(fid)); +} + +static inline void lu_root_fid(struct lu_fid *fid) +{ + fid->f_seq = FID_SEQ_ROOT; + fid->f_oid = FID_OID_ROOT; + fid->f_ver = 0; +} + +static inline void lu_echo_root_fid(struct lu_fid *fid) +{ + fid->f_seq = FID_SEQ_ROOT; + fid->f_oid = FID_OID_ECHO_ROOT; + fid->f_ver = 0; +} + +static inline void lu_update_log_fid(struct lu_fid *fid, __u32 index) +{ + fid->f_seq = FID_SEQ_UPDATE_LOG; + fid->f_oid = index; + fid->f_ver = 0; +} + +static inline void lu_update_log_dir_fid(struct lu_fid *fid, __u32 index) +{ + fid->f_seq = FID_SEQ_UPDATE_LOG_DIR; + fid->f_oid = index; + fid->f_ver = 0; +} + +/** + * Check if a fid is igif or not. + * \param fid the fid to be tested. + * \return true if the fid is an igif; otherwise false. + */ +static inline bool fid_seq_is_igif(__u64 seq) +{ + return seq >= FID_SEQ_IGIF && seq <= FID_SEQ_IGIF_MAX; +} + +static inline bool fid_is_igif(const struct lu_fid *fid) +{ + return fid_seq_is_igif(fid_seq(fid)); +} + +/** + * Check if a fid is idif or not. + * \param fid the fid to be tested. + * \return true if the fid is an idif; otherwise false. + */ +static inline bool fid_seq_is_idif(__u64 seq) +{ + return seq >= FID_SEQ_IDIF && seq <= FID_SEQ_IDIF_MAX; +} + +static inline bool fid_is_idif(const struct lu_fid *fid) +{ + return fid_seq_is_idif(fid_seq(fid)); +} + +static inline bool fid_is_local_file(const struct lu_fid *fid) +{ + return fid_seq_is_local_file(fid_seq(fid)); +} + +static inline bool fid_seq_is_norm(__u64 seq) +{ + return (seq >= FID_SEQ_NORMAL); +} + +static inline bool fid_is_norm(const struct lu_fid *fid) +{ + return fid_seq_is_norm(fid_seq(fid)); +} + +static inline int fid_is_layout_rbtree(const struct lu_fid *fid) +{ + return fid_seq(fid) == FID_SEQ_LAYOUT_RBTREE; +} + +static inline bool fid_seq_is_update_log(__u64 seq) +{ + return seq == FID_SEQ_UPDATE_LOG; +} + +static inline bool fid_is_update_log(const struct lu_fid *fid) +{ + return fid_seq_is_update_log(fid_seq(fid)); +} + +static inline bool fid_seq_is_update_log_dir(__u64 seq) +{ + return seq == FID_SEQ_UPDATE_LOG_DIR; +} + +static inline bool fid_is_update_log_dir(const struct lu_fid *fid) +{ + return fid_seq_is_update_log_dir(fid_seq(fid)); +} + +/* convert an OST objid into an IDIF FID SEQ number */ +static inline __u64 fid_idif_seq(__u64 id, __u32 ost_idx) +{ + return FID_SEQ_IDIF | (ost_idx << 16) | ((id >> 32) & 0xffff); +} + +/* convert a packed IDIF FID into an OST objid */ +static inline __u64 fid_idif_id(__u64 seq, __u32 oid, __u32 ver) +{ + return ((__u64)ver << 48) | ((seq & 0xffff) << 32) | oid; +} + +static inline __u32 idif_ost_idx(__u64 seq) +{ + return (seq >> 16) & 0xffff; +} + +/* extract ost index from IDIF FID */ +static inline __u32 fid_idif_ost_idx(const struct lu_fid *fid) +{ + return idif_ost_idx(fid_seq(fid)); +} + +/* Check whether the fid is for LAST_ID */ +static inline bool fid_is_last_id(const struct lu_fid *fid) +{ + return !fid_oid(fid) && fid_seq(fid) != FID_SEQ_UPDATE_LOG && + fid_seq(fid) != FID_SEQ_UPDATE_LOG_DIR; +} + +/** + * Get inode number from an igif. + * \param fid an igif to get inode number from. + * \return inode number for the igif. + */ +static inline ino_t lu_igif_ino(const struct lu_fid *fid) +{ + return fid_seq(fid); +} + +/** + * Get inode generation from an igif. + * \param fid an igif to get inode generation from. + * \return inode generation for the igif. + */ +static inline __u32 lu_igif_gen(const struct lu_fid *fid) +{ + return fid_oid(fid); +} + +/** + * Build igif from the inode number/generation. + */ +static inline void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen) +{ + fid->f_seq = ino; + fid->f_oid = gen; + fid->f_ver = 0; +} + +/* + * Fids are transmitted across network (in the sender byte-ordering), + * and stored on disk in big-endian order. + */ +static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src) +{ + dst->f_seq = __cpu_to_le64(fid_seq(src)); + dst->f_oid = __cpu_to_le32(fid_oid(src)); + dst->f_ver = __cpu_to_le32(fid_ver(src)); +} + +static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src) +{ + dst->f_seq = __le64_to_cpu(fid_seq(src)); + dst->f_oid = __le32_to_cpu(fid_oid(src)); + dst->f_ver = __le32_to_cpu(fid_ver(src)); +} + +static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src) +{ + dst->f_seq = __cpu_to_be64(fid_seq(src)); + dst->f_oid = __cpu_to_be32(fid_oid(src)); + dst->f_ver = __cpu_to_be32(fid_ver(src)); +} + +static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src) +{ + dst->f_seq = __be64_to_cpu(fid_seq(src)); + dst->f_oid = __be32_to_cpu(fid_oid(src)); + dst->f_ver = __be32_to_cpu(fid_ver(src)); +} + +static inline bool fid_is_sane(const struct lu_fid *fid) +{ + return fid && ((fid_seq(fid) >= FID_SEQ_START && !fid_ver(fid)) || + fid_is_igif(fid) || fid_is_idif(fid) || + fid_seq_is_rsvd(fid_seq(fid))); +} + +static inline bool lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1) +{ + return !memcmp(f0, f1, sizeof(*f0)); +} + +static inline int lu_fid_cmp(const struct lu_fid *f0, + const struct lu_fid *f1) +{ + if (fid_seq(f0) != fid_seq(f1)) + return fid_seq(f0) > fid_seq(f1) ? 1 : -1; + + if (fid_oid(f0) != fid_oid(f1)) + return fid_oid(f0) > fid_oid(f1) ? 1 : -1; + + if (fid_ver(f0) != fid_ver(f1)) + return fid_ver(f0) > fid_ver(f1) ? 1 : -1; + + return 0; +} +#endif diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_ostid.h b/drivers/staging/lustre/lustre/include/lustre/lustre_ostid.h new file mode 100644 index 0000000..140efb1 --- /dev/null +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_ostid.h @@ -0,0 +1,233 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.html + * + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, 2014, Intel Corporation. + * + * Copyright 2015 Cray Inc, all rights reserved. + * Author: Ben Evans. + * + * Define ost_id associated functions + */ + +#ifndef _LUSTRE_OSTID_H_ +#define _LUSTRE_OSTID_H_ + +#include +#include + +static inline __u64 lmm_oi_id(const struct ost_id *oi) +{ + return oi->oi.oi_id; +} + +static inline __u64 lmm_oi_seq(const struct ost_id *oi) +{ + return oi->oi.oi_seq; +} + +static inline void lmm_oi_set_seq(struct ost_id *oi, __u64 seq) +{ + oi->oi.oi_seq = seq; +} + +static inline void lmm_oi_set_id(struct ost_id *oi, __u64 oid) +{ + oi->oi.oi_id = oid; +} + +static inline void lmm_oi_le_to_cpu(struct ost_id *dst_oi, + const struct ost_id *src_oi) +{ + dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq); +} + +static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi, + const struct ost_id *src_oi) +{ + dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq); +} + +/* extract OST sequence (group) from a wire ost_id (id/seq) pair */ +static inline __u64 ostid_seq(const struct ost_id *ostid) +{ + if (fid_seq_is_mdt0(ostid->oi.oi_seq)) + return FID_SEQ_OST_MDT0; + + if (fid_seq_is_default(ostid->oi.oi_seq)) + return FID_SEQ_LOV_DEFAULT; + + if (fid_is_idif(&ostid->oi_fid)) + return FID_SEQ_OST_MDT0; + + return fid_seq(&ostid->oi_fid); +} + +/* extract OST objid from a wire ost_id (id/seq) pair */ +static inline __u64 ostid_id(const struct ost_id *ostid) +{ + if (fid_seq_is_mdt0(ostid->oi.oi_seq)) + return ostid->oi.oi_id & IDIF_OID_MASK; + + if (fid_seq_is_default(ostid->oi.oi_seq)) + return ostid->oi.oi_id; + + if (fid_is_idif(&ostid->oi_fid)) + return fid_idif_id(fid_seq(&ostid->oi_fid), + fid_oid(&ostid->oi_fid), 0); + + return fid_oid(&ostid->oi_fid); +} + +static inline void ostid_set_seq(struct ost_id *oi, __u64 seq) +{ + if (fid_seq_is_mdt0(seq) || fid_seq_is_default(seq)) { + oi->oi.oi_seq = seq; + } else { + oi->oi_fid.f_seq = seq; + /* + * Note: if f_oid + f_ver is zero, we need init it + * to be 1, otherwise, ostid_seq will treat this + * as old ostid (oi_seq == 0) + */ + if (!oi->oi_fid.f_oid && !oi->oi_fid.f_ver) + oi->oi_fid.f_oid = LUSTRE_FID_INIT_OID; + } +} + +static inline void ostid_set_seq_mdt0(struct ost_id *oi) +{ + ostid_set_seq(oi, FID_SEQ_OST_MDT0); +} + +static inline void ostid_set_seq_echo(struct ost_id *oi) +{ + ostid_set_seq(oi, FID_SEQ_ECHO); +} + +static inline void ostid_set_seq_llog(struct ost_id *oi) +{ + ostid_set_seq(oi, FID_SEQ_LLOG); +} + +/** + * Note: we need check oi_seq to decide where to set oi_id, + * so oi_seq should always be set ahead of oi_id. + */ +static inline int ostid_set_id(struct ost_id *oi, __u64 oid) +{ + if (fid_seq_is_mdt0(oi->oi.oi_seq)) { + if (oid >= IDIF_MAX_OID) + return -EINVAL; + oi->oi.oi_id = oid; + } else if (fid_is_idif(&oi->oi_fid)) { + if (oid >= IDIF_MAX_OID) + return -EINVAL; + oi->oi_fid.f_seq = fid_idif_seq(oid, + fid_idif_ost_idx(&oi->oi_fid)); + oi->oi_fid.f_oid = oid; + oi->oi_fid.f_ver = oid >> 48; + } else { + if (oid > OBIF_MAX_OID) + return -EINVAL; + oi->oi_fid.f_oid = oid; + } + return 0; +} + +static inline void ostid_cpu_to_le(const struct ost_id *src_oi, + struct ost_id *dst_oi) +{ + if (fid_seq_is_mdt0(src_oi->oi.oi_seq)) { + dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq); + } else { + fid_cpu_to_le(&dst_oi->oi_fid, &src_oi->oi_fid); + } +} + +static inline void ostid_le_to_cpu(const struct ost_id *src_oi, + struct ost_id *dst_oi) +{ + if (fid_seq_is_mdt0(src_oi->oi.oi_seq)) { + dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id); + dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq); + } else { + fid_le_to_cpu(&dst_oi->oi_fid, &src_oi->oi_fid); + } +} + +/* pack any OST FID into an ostid (id/seq) for the wire/disk */ +static inline int fid_to_ostid(const struct lu_fid *fid, struct ost_id *ostid) +{ + int rc = 0; + + if (fid_seq_is_igif(fid->f_seq)) + return -EBADF; + + if (fid_is_idif(fid)) { + ostid_set_seq_mdt0(ostid); + rc = ostid_set_id(ostid, fid_idif_id(fid_seq(fid), + fid_oid(fid), fid_ver(fid))); + } else { + ostid->oi_fid = *fid; + } + + return rc; +} + +/** + * Sigh, because pre-2.4 uses + * struct lov_mds_md_v1 { + * ........ + * __u64 lmm_object_id; + * __u64 lmm_object_seq; + * ...... + * } + * to identify the LOV(MDT) object, and lmm_object_seq will + * be normal_fid, which make it hard to combine these conversion + * to ostid_to FID. so we will do lmm_oi/fid conversion separately + * + * We can tell the lmm_oi by this way, + * 1.8: lmm_object_id = {inode}, lmm_object_gr = 0 + * 2.1: lmm_object_id = {oid < 128k}, lmm_object_seq = FID_SEQ_NORMAL + * 2.4: lmm_oi.f_seq = FID_SEQ_NORMAL, lmm_oi.f_oid = {oid < 128k}, + * lmm_oi.f_ver = 0 + * + * But currently lmm_oi/lsm_oi does not have any "real" usages, + * except for printing some information, and the user can always + * get the real FID from LMA, besides this multiple case check might + * make swab more complicate. So we will keep using id/seq for lmm_oi. + */ + +static inline void fid_to_lmm_oi(const struct lu_fid *fid, + struct ost_id *oi) +{ + oi->oi.oi_id = fid_oid(fid); + oi->oi.oi_seq = fid_seq(fid); +} + +#endif -- 1.8.3.1 From jsimmons at infradead.org Mon Dec 19 17:11:18 2016 From: jsimmons at infradead.org (James Simmons) Date: Mon, 19 Dec 2016 17:11:18 +0000 (GMT) Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: References: <20161217010045.GA140343@beast>, Message-ID: > James, > > > This should be a purely syntactical change, to help out tools - for GCC, I'm pretty sure the meaning of { > } and { NULL } are the same.  Also, I don't think struct randomization does what you're thinking. Yep. I misread his commit message. That is why it didn't make sense to me. > Is there anything written up on kernel struct randomization?  I was trying to find a talk/post from you or > something from LWN, but I couldn't find something about this specifically.  (Probably because I can't find > it among the other stuff that's been written up) > > > - Patrick > > __________________________________________________________________________________________________________ > From: lustre-devel on behalf of James Simmons > > Sent: Monday, December 19, 2016 10:22:58 AM > To: Kees Cook > Cc: devel at driverdev.osuosl.org; Greg Kroah-Hartman; linux-kernel at vger.kernel.org; Oleg Drokin; Vitaly > Fertman; Bruce Korb; Emoly Liu; lustre-devel at lists.lustre.org > Subject: Re: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers   > > > Prepare to mark sensitive kernel structures for randomization by making > > sure they're using designated initializers. These were identified during > > allyesconfig builds of x86, arm, and arm64, with most initializer fixes > > extracted from grsecurity. > > > > Signed-off-by: Kees Cook > > --- > >  drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 2 +- > >  1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > > index 722160784f83..f815827532dc 100644 > > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > > @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, > >        int added = (mode == LCK_NL); > >        int overlaps = 0; > >        int splitted = 0; > > -     const struct ldlm_callback_suite null_cbs = { NULL }; > > +     const struct ldlm_callback_suite null_cbs = { }; > >  > >        CDEBUG(D_DLMTRACE, > >               "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", > > Nak. Filling null_cbs with random data is a bad idea. If you look at > ldlm_lock_create() where this is used you have > > if (cbs) { >         lock->l_blocking_ast = cbs->lcs_blocking; >         lock->l_completion_ast = cbs->lcs_completion; >         lock->l_glimpse_ast = cbs->lcs_glimpse; > } > > Having lock->l_* point to random addresses is a bad idea. > What really needs to be done is proper initialization of that > structure. A bunch of patches will be coming to address this. > _______________________________________________ > lustre-devel mailing list > lustre-devel at lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org > > From jsimmons at infradead.org Mon Dec 19 17:12:48 2016 From: jsimmons at infradead.org (James Simmons) Date: Mon, 19 Dec 2016 17:12:48 +0000 (GMT) Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: References: <20161217010045.GA140343@beast> Message-ID: > On Mon, Dec 19, 2016 at 8:22 AM, James Simmons > >> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > >> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > >> @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, > >> int added = (mode == LCK_NL); > >> int overlaps = 0; > >> int splitted = 0; > >> - const struct ldlm_callback_suite null_cbs = { NULL }; > >> + const struct ldlm_callback_suite null_cbs = { }; > >> > >> CDEBUG(D_DLMTRACE, > >> "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", > > > > Nak. Filling null_cbs with random data is a bad idea. If you look at > > ldlm_lock_create() where this is used you have > > > > if (cbs) { > > lock->l_blocking_ast = cbs->lcs_blocking; > > lock->l_completion_ast = cbs->lcs_completion; > > lock->l_glimpse_ast = cbs->lcs_glimpse; > > } > > > > Having lock->l_* point to random addresses is a bad idea. > > What really needs to be done is proper initialization of that > > structure. A bunch of patches will be coming to address this. > > I'm not understanding the effect of the original difference. If you > specify any initializer, then all fields not specified are filled with > zero bits. Any pointers are, perforce, NULL. That should make both "{ > NULL }" and "{}" equivalent. Maybe a worthwhile change would be to: > > static const struct ldlm_callback_suite null_cbs; I perfer this as well. > then it is not even necessary to specify an initializer. From dan.carpenter at oracle.com Tue Dec 20 07:10:34 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 20 Dec 2016 10:10:34 +0300 Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: References: <20161217010045.GA140343@beast> Message-ID: <20161220071034.GL8176@mwanda> On Mon, Dec 19, 2016 at 08:47:50AM -0800, Bruce Korb wrote: > On Mon, Dec 19, 2016 at 8:22 AM, James Simmons > >> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > >> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > >> @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, > >> int added = (mode == LCK_NL); > >> int overlaps = 0; > >> int splitted = 0; > >> - const struct ldlm_callback_suite null_cbs = { NULL }; > >> + const struct ldlm_callback_suite null_cbs = { }; > >> > >> CDEBUG(D_DLMTRACE, > >> "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", > > > > Nak. Filling null_cbs with random data is a bad idea. If you look at > > ldlm_lock_create() where this is used you have > > > > if (cbs) { > > lock->l_blocking_ast = cbs->lcs_blocking; > > lock->l_completion_ast = cbs->lcs_completion; > > lock->l_glimpse_ast = cbs->lcs_glimpse; > > } > > > > Having lock->l_* point to random addresses is a bad idea. > > What really needs to be done is proper initialization of that > > structure. A bunch of patches will be coming to address this. > > I'm not understanding the effect of the original difference. If you > specify any initializer, then all fields not specified are filled with > zero bits. Any pointers are, perforce, NULL. That should make both "{ > NULL }" and "{}" equivalent. They are equivalent, yes, but people want to use a GCC plugin that randomizes struct layouts for internal structures and the plugin doesn't work when you use struct ordering to initialize the struct. The plugin requires that you use designated intializers. regards, dan carpenter From dan.carpenter at oracle.com Tue Dec 20 10:40:26 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 20 Dec 2016 13:40:26 +0300 Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: References: <20161217010045.GA140343@beast> Message-ID: <20161220104026.GM8176@mwanda> On Mon, Dec 19, 2016 at 04:22:58PM +0000, James Simmons wrote: > > > Prepare to mark sensitive kernel structures for randomization by making > > sure they're using designated initializers. These were identified during > > allyesconfig builds of x86, arm, and arm64, with most initializer fixes > > extracted from grsecurity. > > > > Signed-off-by: Kees Cook > > --- > > drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > > index 722160784f83..f815827532dc 100644 > > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > > @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, > > int added = (mode == LCK_NL); > > int overlaps = 0; > > int splitted = 0; > > - const struct ldlm_callback_suite null_cbs = { NULL }; > > + const struct ldlm_callback_suite null_cbs = { }; > > > > CDEBUG(D_DLMTRACE, > > "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", > > Nak. Filling null_cbs with random data is a bad idea. You've misunderstood. The plugin just changes how the struct is laid out, it doesn't put data into the struct. So this is fine. The places where it's not fine are when the layout is required because it's shared with userspace or set by the hardware. regards, dan carpenter From john.hammond at intel.com Tue Dec 20 14:57:17 2016 From: john.hammond at intel.com (Hammond, John) Date: Tue, 20 Dec 2016 14:57:17 +0000 Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: <20161220071034.GL8176@mwanda> References: <20161217010045.GA140343@beast> <20161220071034.GL8176@mwanda> Message-ID: > On Mon, Dec 19, 2016 at 08:47:50AM -0800, Bruce Korb wrote: > > On Mon, Dec 19, 2016 at 8:22 AM, James Simmons > > >> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > > >> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > > >> @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock > *req, __u64 *flags, > > >> int added = (mode == LCK_NL); > > >> int overlaps = 0; > > >> int splitted = 0; > > >> - const struct ldlm_callback_suite null_cbs = { NULL }; > > >> + const struct ldlm_callback_suite null_cbs = { }; > > >> > > >> CDEBUG(D_DLMTRACE, > > >> "flags %#llx owner %llu pid %u mode %u start %llu end > > >> %llu\n", > > > > > > Nak. Filling null_cbs with random data is a bad idea. If you look at > > > ldlm_lock_create() where this is used you have > > > > > > if (cbs) { > > > lock->l_blocking_ast = cbs->lcs_blocking; > > > lock->l_completion_ast = cbs->lcs_completion; > > > lock->l_glimpse_ast = cbs->lcs_glimpse; } > > > > > > Having lock->l_* point to random addresses is a bad idea. > > > What really needs to be done is proper initialization of that > > > structure. A bunch of patches will be coming to address this. > > > > I'm not understanding the effect of the original difference. If you > > specify any initializer, then all fields not specified are filled with > > zero bits. Any pointers are, perforce, NULL. That should make both "{ > > NULL }" and "{}" equivalent. > > They are equivalent, yes, but people want to use a GCC plugin that randomizes > struct layouts for internal structures and the plugin doesn't work when you use > struct ordering to initialize the struct. The plugin requires that you use > designated intializers. "{ NULL }" is valid ISO C, but unfortunately "{}" is not. From joe at perches.com Tue Dec 20 17:29:55 2016 From: joe at perches.com (Joe Perches) Date: Tue, 20 Dec 2016 09:29:55 -0800 Subject: [lustre-devel] Designated initializers, struct randomization and addressing? In-Reply-To: <20161217010045.GA140343@beast> References: <20161217010045.GA140343@beast> Message-ID: <1482254995.1984.20.camel@perches.com> On Fri, 2016-12-16 at 17:00 -0800, Kees Cook wrote: > Prepare to mark sensitive kernel structures for randomization by making sure they're using designated initializers. About the designated initializer patches, which by themselves are fine of course, and the fundamental randomization plugin, c guarantees that struct member ordering is as specified. how is the code to be verified so that any use of things like offsetof and any address/indexing is not impacted? From dan.carpenter at oracle.com Tue Dec 20 18:52:40 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 20 Dec 2016 21:52:40 +0300 Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: References: <20161217010045.GA140343@beast> <20161220071034.GL8176@mwanda> Message-ID: <20161220185240.GK8244@mwanda> On Tue, Dec 20, 2016 at 08:47:51AM -0800, Bruce Korb wrote: > > > > "{ NULL }" is valid ISO C, but unfortunately "{}" is not. > > Just make the thing "static const" and don't use an initializer. That also works, of course. regards, dan carpenter From dan.carpenter at oracle.com Tue Dec 20 19:07:51 2016 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 20 Dec 2016 22:07:51 +0300 Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: References: <20161217010045.GA140343@beast> <20161220071034.GL8176@mwanda> Message-ID: <20161220190750.GO8176@mwanda> On Tue, Dec 20, 2016 at 02:57:17PM +0000, Hammond, John wrote: > "{ NULL }" is valid ISO C, but unfortunately "{}" is not. In the kernel we don't care. We use lots of GCC extensions. regards, dan carpenter From keescook at chromium.org Tue Dec 20 19:46:35 2016 From: keescook at chromium.org (Kees Cook) Date: Tue, 20 Dec 2016 11:46:35 -0800 Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: <20161220190750.GO8176@mwanda> References: <20161217010045.GA140343@beast> <20161220071034.GL8176@mwanda> <20161220190750.GO8176@mwanda> Message-ID: On Tue, Dec 20, 2016 at 11:07 AM, Dan Carpenter wrote: > On Tue, Dec 20, 2016 at 02:57:17PM +0000, Hammond, John wrote: >> "{ NULL }" is valid ISO C, but unfortunately "{}" is not. > > In the kernel we don't care. We use lots of GCC extensions. We depend on the compiler to do "incomplete zero-initialization" of structures that are not mentioned in an initializer. The reason { NULL } works is because the first field in the structure can take a NULL value, and then the rest are zero-initialized by the compiler. { } is the same thing, but doesn't use ordered initialization. If this style is truly unacceptable to you, then { .somefield = NULL } can work, or as you point out, if it's being initialized later, the static initializer can be dropped entirely. -Kees -- Kees Cook Nexus Security From oleg.drokin at intel.com Tue Dec 27 23:10:27 2016 From: oleg.drokin at intel.com (Oleg Drokin) Date: Tue, 27 Dec 2016 18:10:27 -0500 Subject: [lustre-devel] New tag 2.9.51 Message-ID: <3782A05D-FA82-4CBA-8936-E9E1A0EEEEF4@intel.com> Hello! I just tagged 2.9.51 in Lustre master development branch, this hosts a bunch of backlogged features and other such patches that have been waiting since 2.9.0 was feature and code frozen. Here's the changelog: Alex Zhuravlev (2): LU-6838 llog: limit file size of plain logs LU-8367 osp: do not block orphan cleanup Andreas Dilger (6): LU-8590 utils: remove duplicate code in lgss_sk LU-8813 gss: allow svcgssd to start without "-k" LU-8619 lbuild: update ZFS to use 0.6.5.8 LU-8920 utils: don't print deactivated OSTs in "lfs df" LU-8901 misc: update Intel copyright messages for 2016 LU-3425 utils: rename l_getgroups.8 to l_getidentity.8 Arshad Hussain (3): LU-8586 test: Fix failure due to mixed OST size. LU-8596 tests: lnet-selftest test failed. LU-7952 osp: Move strlen() call below LASSERT() Bhagyesh Dudhediya (1): LU-8627 test: wait on MDS for ost-pool proc entry to update Bob Glossman (1): LU-8925 kernel: kernel update RHEL7.3 [3.10.0-514.2.2.el7] Bruno Faccini (3): LU-6449 hsm: handle completions with non-existent objects LU-6449 mdt: correct status and ChangeLogs for dead objects LU-8295 tests: comply with OBD_RACE() behavior Chennaiah Palla (1): LU-8640 tests: relax time check of sanity-hsm test_16 Dmitry Eremin (5): LU-8703 libcfs: fix error messages LU-8789 build: add files to .gitignore LU-8790 test: Limit lock number by available inodes count LU-8887 ptlrpc: remove unused pc->pc_env LU-8890 ptlrpc: fix module_param in ptlrpcd.c Emoly Liu (2): LU-8809 osp: print more opd_pre information in LASSERTF() LU-8793 tests: add version check to conf-sanity.sh test_99 Fan Yong (3): LU-8740 lfsck: hold lock when access trace file object LU-8810 tests: skip non-crucial LFSCK intermediateness check LU-8886 lfsck: handle -ENODATA for the end of iteration Frank Zago (1): LU-7988 hsm: don't use a ptlrpc_thread struct for the cdt Henri Doreau (2): LU-7264 mdd: refactor changelog handling for XATTR ops LU-8906 mdd: Return rc in mdd_local_file_create() Jadhav Vikram (1): LU-8684 mgs: prevent duplicate pool to be added to the log James Nunez (1): LU-8832 tests: Generalize check of virtual machine James Simmons (4): LU-6142 lnet: change lnet selftest UAPI typedefs to proper structure LU-8836 lprocfs: move lprocfs_stats_[un]lock to a source file LU-8844 llite: delete lloop LU-6142 socklnd: change UAPI typedefs to proper structure Jinshan Xiong (1): LU-4423 lov: check return value of lov_sub_get() John L. Hammond (5): LU-8403 obd: remove OBD_NOTIFY_CREATE LU-7714 osd: propagate errors in osd_objset_open() LU-8739 test: disable DNE in racer for old MDSs LU-8846 lfs: try to unlink volatile file in lfs_migrate() LU-8811 mdc: avoid returning freed request Liang Zhen (1): LU-8867 ksocklnd: ignore timedout TX on closing connection Lokesh Nagappa Jaliminche (1): LU-8364 ldiskfs: fixes for failover mode. Niu Yawei (6): LU-8491 quota: sleep while holding spinlock LU-8801 quota: fix ldiskfs accounting iterator LU-8826 recovery: don't shrink recovery hard time LU-8197 ptlrpc: set correct rq_timeout for normal replay reply LU-6374 tests: wait for zfs commit LU-8807 llite: check reply status in ll_migrate() Oleg Drokin (4): LU-8538 tests: Silence conf-sanity 63 on debug kernel LU-7765 tests: Fix replay-dual test_26 stderr redirection LU-8972 tests: Disable conf-sanity test 101 New tag 2.9.51 Patrick Farrell (3): LU-8272 ldlm: Use interval tree to update kms LU-8515 osc: Send RPCs when extents are full LU-8842 mdc: Make IT_OPEN take lookup bits lock Sebastien Buisson (3): LU-7845 gss: support namespace in lgss_keyring LU-7845 obd: add 'network' client mount option LU-8305 tests: fix fileset setup in sanity-sec Sebastien Piechurski (1): LU-7735 utils: Allow revert of NO_PRIMNODE Sergey Cheremencev (1): LU-8562 osp: fix precreate_cleanup_orphans/precreate_reserve race Steve Guminski (4): LU-6210 libcfs: Change positional struct initializers to C99 LU-8847 tests: llapi_fid_test uses incorrect parameters LU-8776 build: Fix weird inline definitions LU-8724 utils: Use open() instead of opendir() with dirfd() Thomas Stibor (1): LU-8869 build: Fix building of DEB packages Vladimir Saveliev (1): LU-8351 ptlrpc: allow blocking asts to be delayed Wei Liu (1): LU-7605 test: Skip sanityn test_78 Bye, Oleg From khan.tabrez21 at gmail.com Wed Dec 28 14:10:09 2016 From: khan.tabrez21 at gmail.com (Tabrez khan) Date: Wed, 28 Dec 2016 19:40:09 +0530 Subject: [lustre-devel] [PATCH] staging : lustre : Remove braces from single-line body. Message-ID: <1482934209-10857-1-git-send-email-khan.tabrez21@gmail.com> Remove unnecessary braces from single-line if statement. This warning is found using checkpatch.pl. Signed-off-by: Tabrez khan --- drivers/staging/lustre/lustre/ptlrpc/import.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 477d832..b55680b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -1392,9 +1392,9 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) } if (imp->imp_state == LUSTRE_IMP_REPLAY_WAIT) { - if (atomic_read(&imp->imp_replay_inflight) == 0) { + if (atomic_read(&imp->imp_replay_inflight) == 0) IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER); - } + } if (imp->imp_state == LUSTRE_IMP_RECOVER) { -- 2.7.4 From khan.tabrez21 at gmail.com Thu Dec 29 12:20:48 2016 From: khan.tabrez21 at gmail.com (Tabrez khan) Date: Thu, 29 Dec 2016 17:50:48 +0530 Subject: [lustre-devel] [PATCH] staging : lustre : Remove braces from single line body. Message-ID: <1483014048-3262-1-git-send-email-khan.tabrez21@gmail.com> Remove unnecessary braces from single line if statement. This warning is found using checkpatch.pl. Signed-off-by: Tabrez khan --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index f0062d4..098ef1e 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -585,9 +585,9 @@ static ssize_t max_pages_per_rpc_store(struct kobject *kobj, chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_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_SHIFT) { + if (val == 0 || val > ocd->ocd_brw_size >> PAGE_SHIFT) return -ERANGE; - } + spin_lock(&cli->cl_loi_list_lock); cli->cl_max_pages_per_rpc = val; client_adjust_max_dirty(cli); -- 2.7.4 From khan.tabrez21 at gmail.com Thu Dec 29 14:11:26 2016 From: khan.tabrez21 at gmail.com (Tabrez khan) Date: Thu, 29 Dec 2016 19:41:26 +0530 Subject: [lustre-devel] [PATCH] staging:lustre:fixed space coding style in o2iblnd_cb.c Message-ID: <1483020686-3611-1-git-send-email-khan.tabrez21@gmail.com> Space required before assignment operator, to make close to kernel coding style. This error is found using checkpatch.pl. Signed-off-by: Tabrez khan --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index b27de88..ba1782b 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -3276,7 +3276,7 @@ kiblnd_disconnect_conn(struct kib_conn *conn) int kiblnd_connd(void *arg) { - spinlock_t *lock= &kiblnd_data.kib_connd_lock; + spinlock_t *lock = &kiblnd_data.kib_connd_lock; wait_queue_t wait; unsigned long flags; struct kib_conn *conn; -- 2.7.4 From khan.tabrez21 at gmail.com Thu Dec 29 15:39:01 2016 From: khan.tabrez21 at gmail.com (Tabrez khan) Date: Thu, 29 Dec 2016 21:09:01 +0530 Subject: [lustre-devel] [PATCH] staging:lustre:fixed space coding style in o2iblnd_cb.c Message-ID: <1483025941-2726-1-git-send-email-khan.tabrez21@gmail.com> Space required before assignment operator, to make close to kernel coding style. This error is found using checkpatch.pl. Signed-off-by: Tabrez khan --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index b27de88..ba1782b 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -3276,7 +3276,7 @@ kiblnd_disconnect_conn(struct kib_conn *conn) int kiblnd_connd(void *arg) { - spinlock_t *lock= &kiblnd_data.kib_connd_lock; + spinlock_t *lock = &kiblnd_data.kib_connd_lock; wait_queue_t wait; unsigned long flags; struct kib_conn *conn; -- 2.7.4 From khan.tabrez21 at gmail.com Thu Dec 29 20:02:13 2016 From: khan.tabrez21 at gmail.com (Tabrez khan) Date: Fri, 30 Dec 2016 01:32:13 +0530 Subject: [lustre-devel] [PATCH] staging:lustre:remove braces from single-line body Message-ID: <1483041733-10362-1-git-send-email-khan.tabrez21@gmail.com> Remove unnecessary braces from single line if statement. This warning is found using checkpatch.pl. Signed-off-by: Tabrez khan --- drivers/staging/lustre/lustre/obdecho/echo_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 505582f..3050fa7 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -1694,9 +1694,9 @@ static int echo_client_connect(const struct lu_env *env, struct lustre_handle conn = { 0 }; rc = class_connect(&conn, src, cluuid); - if (rc == 0) { + if (rc == 0) *exp = class_conn2export(&conn); - } + return rc; } -- 2.7.4 From kedrot at gmail.com Mon Dec 26 15:44:03 2016 From: kedrot at gmail.com (Guillermo O. Freschi) Date: Mon, 26 Dec 2016 15:44:03 -0000 Subject: [lustre-devel] [PATCH 1/2] Fixed signedness check Message-ID: <20161226154339.8916-1-kedrot@gmail.com> Was `unsigned int`, but `enum`s are signed. Signed-off-by: Guillermo O. Freschi --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index a4a291acb659..f4cbc89b4f24 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1148,7 +1148,7 @@ static int lock_matches(struct ldlm_lock *lock, struct lock_match_data *data) return INTERVAL_ITER_STOP; } -static unsigned int itree_overlap_cb(struct interval_node *in, void *args) +static enum interval_iter itree_overlap_cb(struct interval_node *in, void *args) { struct ldlm_interval *node = to_ldlm_interval(in); struct lock_match_data *data = args; -- 2.11.0 From karthik.188 at gmail.com Fri Dec 23 15:42:13 2016 From: karthik.188 at gmail.com (Karthik Nayak) Date: Fri, 23 Dec 2016 15:42:13 -0000 Subject: [lustre-devel] [PATCH] staging: lustre: selftest: Make brw_inject_one_error() static Message-ID: <20161223154244.29145-1-Karthik.188@gmail.com> Since the function brw_inject_one_error() is used only within brw_test.c, make it static. This was reported as a warning by sparse. Signed-off-by: Karthik Nayak --- drivers/staging/lustre/lnet/selftest/brw_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index 67b460f..b9ac34e 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -136,7 +136,7 @@ brw_client_init(struct sfw_test_instance *tsi) return 0; } -int brw_inject_one_error(void) +static int brw_inject_one_error(void) { struct timespec64 ts; -- 2.10.2 From bruce.korb at gmail.com Mon Dec 19 16:48:31 2016 From: bruce.korb at gmail.com (Bruce Korb) Date: Mon, 19 Dec 2016 16:48:31 -0000 Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: References: <20161217010045.GA140343@beast> Message-ID: On Mon, Dec 19, 2016 at 8:22 AM, James Simmons >> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c >> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c >> @@ -143,7 +143,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, >> int added = (mode == LCK_NL); >> int overlaps = 0; >> int splitted = 0; >> - const struct ldlm_callback_suite null_cbs = { NULL }; >> + const struct ldlm_callback_suite null_cbs = { }; >> >> CDEBUG(D_DLMTRACE, >> "flags %#llx owner %llu pid %u mode %u start %llu end %llu\n", > > Nak. Filling null_cbs with random data is a bad idea. If you look at > ldlm_lock_create() where this is used you have > > if (cbs) { > lock->l_blocking_ast = cbs->lcs_blocking; > lock->l_completion_ast = cbs->lcs_completion; > lock->l_glimpse_ast = cbs->lcs_glimpse; > } > > Having lock->l_* point to random addresses is a bad idea. > What really needs to be done is proper initialization of that > structure. A bunch of patches will be coming to address this. I'm not understanding the effect of the original difference. If you specify any initializer, then all fields not specified are filled with zero bits. Any pointers are, perforce, NULL. That should make both "{ NULL }" and "{}" equivalent. Maybe a worthwhile change would be to: static const struct ldlm_callback_suite null_cbs; then it is not even necessary to specify an initializer. From bruce.korb at gmail.com Tue Dec 20 16:48:33 2016 From: bruce.korb at gmail.com (Bruce Korb) Date: Tue, 20 Dec 2016 16:48:33 -0000 Subject: [lustre-devel] [PATCH] staging: lustre: ldlm: use designated initializers In-Reply-To: References: <20161217010045.GA140343@beast> <20161220071034.GL8176@mwanda> Message-ID: > > "{ NULL }" is valid ISO C, but unfortunately "{}" is not. Just make the thing "static const" and don't use an initializer. From tglx at linutronix.de Wed Dec 21 19:29:03 2016 From: tglx at linutronix.de (Thomas Gleixner) Date: Wed, 21 Dec 2016 19:29:03 -0000 Subject: [lustre-devel] [patch 05/10] staging/lustre/libcfs: Convert to hotplug state machine References: <20161221191947.089046759@linutronix.de> Message-ID: <20161221192111.922872524@linutronix.de> From: Anna-Maria Gleixner Install the callbacks via the state machine. No functional change. Signed-off-by: Anna-Maria Gleixner Signed-off-by: Sebastian Andrzej Siewior Cc: devel at driverdev.osuosl.org Cc: Andreas Dilger Cc: Greg Kroah-Hartman Cc: Oleg Drokin Cc: rt at linutronix.de Cc: lustre-devel at lists.lustre.org Link: http://lkml.kernel.org/r/20161202110027.htzzeervzkoc4muv at linutronix.de Signed-off-by: Thomas Gleixner --- drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 85 ++++++++++--------- include/linux/cpuhotplug.h | 1 2 files changed, 46 insertions(+), 40 deletions(-) --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c @@ -967,48 +967,38 @@ cfs_cpt_table_create_pattern(char *patte } #ifdef CONFIG_HOTPLUG_CPU -static int -cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) -{ - unsigned int cpu = (unsigned long)hcpu; - bool warn; - - switch (action) { - case CPU_DEAD: - case CPU_DEAD_FROZEN: - case CPU_ONLINE: - case CPU_ONLINE_FROZEN: - spin_lock(&cpt_data.cpt_lock); - cpt_data.cpt_version++; - spin_unlock(&cpt_data.cpt_lock); - /* Fall through */ - default: - if (action != CPU_DEAD && action != CPU_DEAD_FROZEN) { - CDEBUG(D_INFO, "CPU changed [cpu %u action %lx]\n", - cpu, action); - break; - } +static enum cpuhp_state lustre_cpu_online; - mutex_lock(&cpt_data.cpt_mutex); - /* if all HTs in a core are offline, it may break affinity */ - cpumask_copy(cpt_data.cpt_cpumask, - topology_sibling_cpumask(cpu)); - warn = cpumask_any_and(cpt_data.cpt_cpumask, - cpu_online_mask) >= nr_cpu_ids; - mutex_unlock(&cpt_data.cpt_mutex); - CDEBUG(warn ? D_WARNING : D_INFO, - "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u action: %lx]\n", - cpu, action); - } +static void cfs_cpu_incr_cpt_version(void) +{ + spin_lock(&cpt_data.cpt_lock); + cpt_data.cpt_version++; + spin_unlock(&cpt_data.cpt_lock); +} - return NOTIFY_OK; +static int cfs_cpu_online(unsigned int cpu) +{ + cfs_cpu_incr_cpt_version(); + return 0; } -static struct notifier_block cfs_cpu_notifier = { - .notifier_call = cfs_cpu_notify, - .priority = 0 -}; +static int cfs_cpu_dead(unsigned int cpu) +{ + bool warn; + + cfs_cpu_incr_cpt_version(); + mutex_lock(&cpt_data.cpt_mutex); + /* if all HTs in a core are offline, it may break affinity */ + cpumask_copy(cpt_data.cpt_cpumask, topology_sibling_cpumask(cpu)); + warn = cpumask_any_and(cpt_data.cpt_cpumask, + cpu_online_mask) >= nr_cpu_ids; + mutex_unlock(&cpt_data.cpt_mutex); + CDEBUG(warn ? D_WARNING : D_INFO, + "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u]\n", + cpu); + return 0; +} #endif void @@ -1018,7 +1008,9 @@ cfs_cpu_fini(void) cfs_cpt_table_free(cfs_cpt_table); #ifdef CONFIG_HOTPLUG_CPU - unregister_hotcpu_notifier(&cfs_cpu_notifier); + if (lustre_cpu_online > 0) + cpuhp_remove_state_nocalls(lustre_cpu_online); + cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD); #endif if (cpt_data.cpt_cpumask) LIBCFS_FREE(cpt_data.cpt_cpumask, cpumask_size()); @@ -1027,6 +1019,8 @@ cfs_cpu_fini(void) int cfs_cpu_init(void) { + int ret = 0; + LASSERT(!cfs_cpt_table); memset(&cpt_data, 0, sizeof(cpt_data)); @@ -1041,8 +1035,19 @@ cfs_cpu_init(void) mutex_init(&cpt_data.cpt_mutex); #ifdef CONFIG_HOTPLUG_CPU - register_hotcpu_notifier(&cfs_cpu_notifier); + ret = cpuhp_setup_state_nocalls(CPUHP_LUSTRE_CFS_DEAD, + "staging/lustre/cfe:dead", NULL, + cfs_cpu_dead); + if (ret < 0) + goto failed; + ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, + "staging/lustre/cfe:online", + cfs_cpu_online, NULL); + if (ret < 0) + goto failed; + lustre_cpu_online = ret; #endif + ret = -EINVAL; if (*cpu_pattern) { cfs_cpt_table = cfs_cpt_table_create_pattern(cpu_pattern); @@ -1075,7 +1080,7 @@ cfs_cpu_init(void) failed: cfs_cpu_fini(); - return -1; + return ret; } #endif --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -41,6 +41,7 @@ enum cpuhp_state { CPUHP_NET_DEV_DEAD, CPUHP_PCI_XGENE_DEAD, CPUHP_IOMMU_INTEL_DEAD, + CPUHP_LUSTRE_CFS_DEAD, CPUHP_SCSI_BNX2FC_DEAD, CPUHP_SCSI_BNX2I_DEAD, CPUHP_WORKQUEUE_PREP, From geliangtang at gmail.com Tue Dec 20 13:57:06 2016 From: geliangtang at gmail.com (Geliang Tang) Date: Tue, 20 Dec 2016 13:57:06 -0000 Subject: [lustre-devel] [PATCH] staging: lustre: osc: use rb_entry_safe Message-ID: <0d014cb5a85c053f88ef7d53e5e3c1514f4e28c0.1482206001.git.geliangtang@gmail.com> Use rb_entry_safe() instead of container_of() to simplify the code. Signed-off-by: Geliang Tang --- drivers/staging/lustre/lustre/osc/osc_cache.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index b0f030c..6048df9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -142,10 +142,7 @@ static const char *oes_strings[] = { static inline struct osc_extent *rb_extent(struct rb_node *n) { - if (!n) - return NULL; - - return container_of(n, struct osc_extent, oe_node); + return rb_entry_safe(n, struct osc_extent, oe_node); } static inline struct osc_extent *next_extent(struct osc_extent *ext) -- 2.9.3 From kedrot at gmail.com Mon Dec 26 15:44:05 2016 From: kedrot at gmail.com (Guillermo O. Freschi) Date: Mon, 26 Dec 2016 15:44:05 -0000 Subject: [lustre-devel] [PATCH 2/2] Style fixes In-Reply-To: <20161226154339.8916-1-kedrot@gmail.com> References: <20161226154339.8916-1-kedrot@gmail.com> Message-ID: <20161226154339.8916-2-kedrot@gmail.com> Missing braces on `if` statement; misaligned parameter. Signed-off-by: Guillermo O. Freschi --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index f4cbc89b4f24..a23e7ada3891 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1024,11 +1024,11 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list) if (work_list && lock->l_completion_ast) ldlm_add_ast_work_item(lock, NULL, work_list); - if (res->lr_type == LDLM_PLAIN || res->lr_type == LDLM_IBITS) + if (res->lr_type == LDLM_PLAIN || res->lr_type == LDLM_IBITS) { ldlm_grant_lock_with_skiplist(lock); - else if (res->lr_type == LDLM_EXTENT) + } else if (res->lr_type == LDLM_EXTENT) { ldlm_extent_add_lock(res, lock); - else if (res->lr_type == LDLM_FLOCK) { + } else if (res->lr_type == LDLM_FLOCK) { /* * We should not add locks to granted list in the following cases: * - this is an UNLOCK but not a real lock; @@ -1040,8 +1040,9 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list) ldlm_is_test_lock(lock) || ldlm_is_flock_deadlock(lock)) return; ldlm_resource_add_lock(res, &res->lr_granted, lock); - } else + } else { LBUG(); + } ldlm_pool_add(&ldlm_res_to_ns(res)->ns_pool, lock); } @@ -1481,7 +1482,8 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lustre_swab_ost_lvb_v1); else lvb = req_capsule_server_sized_swab_get(pill, - &RMF_DLM_LVB, size, + &RMF_DLM_LVB, + size, lustre_swab_ost_lvb_v1); if (unlikely(!lvb)) { LDLM_ERROR(lock, "no LVB"); -- 2.11.0