Lines Matching refs:ds
322 struct dm_deferred_set *ds; member
337 struct dm_deferred_set *ds; in dm_deferred_set_create() local
339 ds = kmalloc(sizeof(*ds), GFP_KERNEL); in dm_deferred_set_create()
340 if (!ds) in dm_deferred_set_create()
343 spin_lock_init(&ds->lock); in dm_deferred_set_create()
344 ds->current_entry = 0; in dm_deferred_set_create()
345 ds->sweeper = 0; in dm_deferred_set_create()
347 ds->entries[i].ds = ds; in dm_deferred_set_create()
348 ds->entries[i].count = 0; in dm_deferred_set_create()
349 INIT_LIST_HEAD(&ds->entries[i].work_items); in dm_deferred_set_create()
352 return ds; in dm_deferred_set_create()
356 void dm_deferred_set_destroy(struct dm_deferred_set *ds) in dm_deferred_set_destroy() argument
358 kfree(ds); in dm_deferred_set_destroy()
362 struct dm_deferred_entry *dm_deferred_entry_inc(struct dm_deferred_set *ds) in dm_deferred_entry_inc() argument
367 spin_lock_irqsave(&ds->lock, flags); in dm_deferred_entry_inc()
368 entry = ds->entries + ds->current_entry; in dm_deferred_entry_inc()
370 spin_unlock_irqrestore(&ds->lock, flags); in dm_deferred_entry_inc()
381 static void __sweep(struct dm_deferred_set *ds, struct list_head *head) in __sweep() argument
383 while ((ds->sweeper != ds->current_entry) && in __sweep()
384 !ds->entries[ds->sweeper].count) { in __sweep()
385 list_splice_init(&ds->entries[ds->sweeper].work_items, head); in __sweep()
386 ds->sweeper = ds_next(ds->sweeper); in __sweep()
389 if ((ds->sweeper == ds->current_entry) && !ds->entries[ds->sweeper].count) in __sweep()
390 list_splice_init(&ds->entries[ds->sweeper].work_items, head); in __sweep()
397 spin_lock_irqsave(&entry->ds->lock, flags); in dm_deferred_entry_dec()
400 __sweep(entry->ds, head); in dm_deferred_entry_dec()
401 spin_unlock_irqrestore(&entry->ds->lock, flags); in dm_deferred_entry_dec()
408 int dm_deferred_set_add_work(struct dm_deferred_set *ds, struct list_head *work) in dm_deferred_set_add_work() argument
413 spin_lock_irq(&ds->lock); in dm_deferred_set_add_work()
414 if ((ds->sweeper == ds->current_entry) && in dm_deferred_set_add_work()
415 !ds->entries[ds->current_entry].count) in dm_deferred_set_add_work()
418 list_add(work, &ds->entries[ds->current_entry].work_items); in dm_deferred_set_add_work()
419 next_entry = ds_next(ds->current_entry); in dm_deferred_set_add_work()
420 if (!ds->entries[next_entry].count) in dm_deferred_set_add_work()
421 ds->current_entry = next_entry; in dm_deferred_set_add_work()
423 spin_unlock_irq(&ds->lock); in dm_deferred_set_add_work()