ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* drivers/block/rbd.c: atomic_inc_return_safe() & atomic_dec_return_safe()
@ 2020-10-02 22:34 Shuah Khan
  2020-10-02 23:44 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Shuah Khan @ 2020-10-02 22:34 UTC (permalink / raw)
  To: idryomov, dongsheng.yang, axboe
  Cc: ceph-devel, Linux Kernel Mailing List, Shuah Khan,
	Greg Kroah-Hartman, Kees Cook

All,

I came across these atomic_inc_return_safe() & atomic_dec_return_safe()
functions that hold the counters at safe values.

atomic_inc_return_safe()

If the counter is already 0 it will not be incremented.
If the counter is already at its maximum value returns
-EINVAL without updating it.

atomic_dec_return_safe()

Decrement the counter.  Return the resulting value, or -EINVAL

These two routines are static and only used in rbd.c.

Can these become part of atomic_t ops?

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-02 23:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-02 22:34 drivers/block/rbd.c: atomic_inc_return_safe() & atomic_dec_return_safe() Shuah Khan
2020-10-02 23:44 ` Jens Axboe
2020-10-02 23:50   ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).