~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/ceph/ceph_frag.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef FS_CEPH_FRAG_H
  3 #define FS_CEPH_FRAG_H
  4 
  5 /*
  6  * "Frags" are a way to describe a subset of a 32-bit number space,
  7  * using a mask and a value to match against that mask.  Any given frag
  8  * (subset of the number space) can be partitioned into 2^n sub-frags.
  9  *
 10  * Frags are encoded into a 32-bit word:
 11  *   8 upper bits = "bits"
 12  *  24 lower bits = "value"
 13  * (We could go to 5+27 bits, but who cares.)
 14  *
 15  * We use the _most_ significant bits of the 24 bit value.  This makes
 16  * values logically sort.
 17  *
 18  * Unfortunately, because the "bits" field is still in the high bits, we
 19  * can't sort encoded frags numerically.  However, it does allow you
 20  * to feed encoded frags as values into frag_contains_value.
 21  */
 22 static inline __u32 ceph_frag_make(__u32 b, __u32 v)
 23 {
 24         return (b << 24) |
 25                 (v & (0xffffffu << (24-b)) & 0xffffffu);
 26 }
 27 static inline __u32 ceph_frag_bits(__u32 f)
 28 {
 29         return f >> 24;
 30 }
 31 static inline __u32 ceph_frag_value(__u32 f)
 32 {
 33         return f & 0xffffffu;
 34 }
 35 static inline __u32 ceph_frag_mask(__u32 f)
 36 {
 37         return (0xffffffu << (24-ceph_frag_bits(f))) & 0xffffffu;
 38 }
 39 static inline __u32 ceph_frag_mask_shift(__u32 f)
 40 {
 41         return 24 - ceph_frag_bits(f);
 42 }
 43 
 44 static inline bool ceph_frag_contains_value(__u32 f, __u32 v)
 45 {
 46         return (v & ceph_frag_mask(f)) == ceph_frag_value(f);
 47 }
 48 
 49 static inline __u32 ceph_frag_make_child(__u32 f, int by, int i)
 50 {
 51         int newbits = ceph_frag_bits(f) + by;
 52         return ceph_frag_make(newbits,
 53                          ceph_frag_value(f) | (i << (24 - newbits)));
 54 }
 55 static inline bool ceph_frag_is_leftmost(__u32 f)
 56 {
 57         return ceph_frag_value(f) == 0;
 58 }
 59 static inline bool ceph_frag_is_rightmost(__u32 f)
 60 {
 61         return ceph_frag_value(f) == ceph_frag_mask(f);
 62 }
 63 static inline __u32 ceph_frag_next(__u32 f)
 64 {
 65         return ceph_frag_make(ceph_frag_bits(f),
 66                          ceph_frag_value(f) + (0x1000000 >> ceph_frag_bits(f)));
 67 }
 68 
 69 /*
 70  * comparator to sort frags logically, as when traversing the
 71  * number space in ascending order...
 72  */
 73 int ceph_frag_compare(__u32 a, __u32 b);
 74 
 75 #endif
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php