Whamcloud - gitweb
LU-11848 lov: FIEMAP support for PFL and FLR file
[fs/lustre-release.git] / lustre / include / uapi / linux / lustre / lustre_fiemap.h
index cee135b..ddea799 100644 (file)
@@ -29,8 +29,6 @@
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  *
- * lustre/include/lustre/ll_fiemap.h
- *
  * FIEMAP data structures and flags. This header file will be used until
  * fiemap.h is available in the upstream kernel.
  *
 #ifndef _LUSTRE_FIEMAP_H
 #define _LUSTRE_FIEMAP_H
 
-#ifndef __KERNEL__
 #include <stddef.h>
 #include <linux/fiemap.h>
-#endif
+#include <linux/types.h>
 
-/* XXX: We use fiemap_extent::fe_reserved[0] */
+/**
+ * XXX: We use fiemap_extent::fe_reserved[0], notice the high 16bits of it
+ * is used to locate the stripe number starting from the very beginning to
+ * resume the fiemap call.
+ */
 #define fe_device      fe_reserved[0]
 
-static inline size_t fiemap_count_to_size(size_t extent_count)
+static inline int get_fe_device(struct fiemap_extent *fe)
+{
+       return fe->fe_device & 0xffff;
+}
+static inline void set_fe_device(struct fiemap_extent *fe, int devno)
+{
+       fe->fe_device = (fe->fe_device & 0xffff0000) | (devno & 0xffff);
+}
+static inline int get_fe_stripenr(struct fiemap_extent *fe)
+{
+       return fe->fe_device >> 16;
+}
+static inline void set_fe_stripenr(struct fiemap_extent *fe, int nr)
+{
+       fe->fe_device = (fe->fe_device & 0xffff) | (nr << 16);
+}
+static inline void set_fe_device_stripenr(struct fiemap_extent *fe, int devno,
+                                         int nr)
+{
+       fe->fe_device = (nr << 16) | (devno & 0xffff);
+}
+
+static inline __kernel_size_t fiemap_count_to_size(__kernel_size_t extent_count)
 {
        return sizeof(struct fiemap) + extent_count *
                                       sizeof(struct fiemap_extent);
 }
 
-static inline unsigned fiemap_size_to_count(size_t array_size)
+static inline unsigned int fiemap_size_to_count(__kernel_size_t array_size)
 {
        return (array_size - sizeof(struct fiemap)) /
               sizeof(struct fiemap_extent);
@@ -67,8 +90,6 @@ static inline unsigned fiemap_size_to_count(size_t array_size)
 #undef FIEMAP_FLAGS_COMPAT
 #endif
 
-/* Lustre specific flags - use a high bit, don't conflict with upstream flag */
-#define FIEMAP_EXTENT_NO_DIRECT 0x40000000 /* Data mapping undefined */
 #define FIEMAP_EXTENT_NET       0x80000000 /* Data stored remotely.
                                            * Sets NO_DIRECT flag */