mirror of https://gitee.com/openkylin/linux.git
staging: lustre: osc_cache: Use list_for_each_entry_safe
Doubly linked lists which are iterated using list_empty and list_entry macros have been replaced with list_for_each_entry_safe macro. This makes the iteration simpler and more readable. This patch replaces the while loop containing list_empty and list_entry with list_for_each_entry_safe. This was done with Coccinelle. @@ expression E1; identifier I1, I2; type T; iterator name list_for_each_entry_safe; @@ T *I1; + T *tmp; ... - while (list_empty(&E1) == 0) + list_for_each_entry_safe (I1, tmp, &E1, I2) { ...when != T *I1; - I1 = list_entry(E1.next, T, I2); ... } Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8adddc36b1
commit
4a81ce53a6
|
@ -1905,13 +1905,12 @@ static int get_write_extents(struct osc_object *obj, struct list_head *rpclist)
|
||||||
{
|
{
|
||||||
struct client_obd *cli = osc_cli(obj);
|
struct client_obd *cli = osc_cli(obj);
|
||||||
struct osc_extent *ext;
|
struct osc_extent *ext;
|
||||||
|
struct osc_extent *temp;
|
||||||
int page_count = 0;
|
int page_count = 0;
|
||||||
unsigned int max_pages = cli->cl_max_pages_per_rpc;
|
unsigned int max_pages = cli->cl_max_pages_per_rpc;
|
||||||
|
|
||||||
LASSERT(osc_object_is_locked(obj));
|
LASSERT(osc_object_is_locked(obj));
|
||||||
while (!list_empty(&obj->oo_hp_exts)) {
|
list_for_each_entry_safe(ext, temp, &obj->oo_hp_exts, oe_link) {
|
||||||
ext = list_entry(obj->oo_hp_exts.next, struct osc_extent,
|
|
||||||
oe_link);
|
|
||||||
LASSERT(ext->oe_state == OES_CACHE);
|
LASSERT(ext->oe_state == OES_CACHE);
|
||||||
if (!try_to_add_extent_for_io(cli, ext, rpclist, &page_count,
|
if (!try_to_add_extent_for_io(cli, ext, rpclist, &page_count,
|
||||||
&max_pages))
|
&max_pages))
|
||||||
|
@ -2667,6 +2666,7 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio,
|
||||||
{
|
{
|
||||||
struct client_obd *cli = osc_cli(obj);
|
struct client_obd *cli = osc_cli(obj);
|
||||||
struct osc_extent *ext;
|
struct osc_extent *ext;
|
||||||
|
struct osc_extent *temp;
|
||||||
struct osc_extent *waiting = NULL;
|
struct osc_extent *waiting = NULL;
|
||||||
pgoff_t index;
|
pgoff_t index;
|
||||||
LIST_HEAD(list);
|
LIST_HEAD(list);
|
||||||
|
@ -2726,10 +2726,9 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio,
|
||||||
|
|
||||||
osc_list_maint(cli, obj);
|
osc_list_maint(cli, obj);
|
||||||
|
|
||||||
while (!list_empty(&list)) {
|
list_for_each_entry_safe(ext, temp, &list, oe_link) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
ext = list_entry(list.next, struct osc_extent, oe_link);
|
|
||||||
list_del_init(&ext->oe_link);
|
list_del_init(&ext->oe_link);
|
||||||
|
|
||||||
/* extent may be in OES_ACTIVE state because inode mutex
|
/* extent may be in OES_ACTIVE state because inode mutex
|
||||||
|
|
Loading…
Reference in New Issue