@@ -817,6 +817,10 @@ static inline int obd_pool_new(struct obd_device *obd, char *poolname)
return -EOPNOTSUPP;
}
+ /* Check poolname validity */
+ if (!poolname || poolname[0] == '\0' || lov_pool_is_reserved(poolname))
+ return -EINVAL;
+
rc = OBP(obd, pool_new)(obd, poolname);
return rc;
}
@@ -435,6 +435,17 @@ struct ll_ioc_lease_id {
#define LOV_PATTERN_F_HOLE 0x40000000 /* there is hole in LOV EA */
#define LOV_PATTERN_F_RELEASED 0x80000000 /* HSM released file */
+#define LOV_OFFSET_DEFAULT ((__u16)-1)
+#define LMV_OFFSET_DEFAULT ((__u32)-1)
+
+static inline bool lov_pattern_supported(__u32 pattern)
+{
+ return (pattern & ~LOV_PATTERN_F_RELEASED) == LOV_PATTERN_RAID0 ||
+ (pattern & ~LOV_PATTERN_F_RELEASED) ==
+ (LOV_PATTERN_RAID0 | LOV_PATTERN_OVERSTRIPING) ||
+ (pattern & ~LOV_PATTERN_F_RELEASED) == LOV_PATTERN_MDT;
+}
+
/* RELEASED and MDT patterns are not valid in many places, so rather than
* having many extra checks on lov_pattern_supported, we have this separate
* check for non-released, non-DOM components
@@ -448,15 +459,29 @@ static inline bool lov_pattern_supported_normal_comp(__u32 pattern)
#define LOV_MAXPOOLNAME 15
#define LOV_POOLNAMEF "%.15s"
-#define LOV_OFFSET_DEFAULT ((__u16)-1)
-#define LMV_OFFSET_DEFAULT ((__u32)-1)
+/* The poolname "ignore" is used to force a component creation without pool */
+#define LOV_POOL_IGNORE "ignore"
+/* The poolname "inherit" is used to force a component to inherit the pool from
+ * parent or root directory
+ */
+#define LOV_POOL_INHERIT "inherit"
+/* The poolname "none" is deprecated in 2.15 (same behavior as "inherit") */
+#define LOV_POOL_NONE "none"
-static inline bool lov_pattern_supported(__u32 pattern)
+static inline bool lov_pool_is_ignored(const char *pool)
{
- return (pattern & ~LOV_PATTERN_F_RELEASED) == LOV_PATTERN_RAID0 ||
- (pattern & ~LOV_PATTERN_F_RELEASED) ==
- (LOV_PATTERN_RAID0 | LOV_PATTERN_OVERSTRIPING) ||
- (pattern & ~LOV_PATTERN_F_RELEASED) == LOV_PATTERN_MDT;
+ return pool && strncmp(pool, LOV_POOL_IGNORE, LOV_MAXPOOLNAME) == 0;
+}
+
+static inline bool lov_pool_is_inherited(const char *pool)
+{
+ return pool && (strncmp(pool, LOV_POOL_INHERIT, LOV_MAXPOOLNAME) == 0 ||
+ strncmp(pool, LOV_POOL_NONE, LOV_MAXPOOLNAME) == 0);
+}
+
+static inline bool lov_pool_is_reserved(const char *pool)
+{
+ return lov_pool_is_ignored(pool) || lov_pool_is_inherited(pool);
}
#define LOV_MIN_STRIPE_BITS 16 /* maximum PAGE_SIZE (ia64), power of 2 */