Whamcloud - gitweb
LU-1303 lod: functions to manipulate sub-devices
[fs/lustre-release.git] / libcfs / include / libcfs / bitmap.h
index 9f54a73..5436f3c 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -26,7 +24,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -92,9 +90,20 @@ int cfs_bitmap_check_empty(cfs_bitmap_t *bitmap)
         return cfs_find_first_bit(bitmap->data, bitmap->size) == bitmap->size;
 }
 
+static inline
+void cfs_bitmap_copy(cfs_bitmap_t *new, cfs_bitmap_t *old)
+{
+       int newsize;
+
+       LASSERT(new->size >= old->size);
+       newsize = new->size;
+       memcpy(new, old, CFS_BITMAP_SIZE(old->size));
+       new->size = newsize;
+}
+
 #define cfs_foreach_bit(bitmap, pos) \
        for((pos)=cfs_find_first_bit((bitmap)->data, bitmap->size);   \
-            (pos) < (bitmap)->size;                               \
-            (pos) = cfs_find_next_bit((bitmap)->data, (bitmap)->size, (pos)))
+           (pos) < (bitmap)->size;                               \
+           (pos) = cfs_find_next_bit((bitmap)->data, (bitmap)->size, (pos)+1))
 
 #endif