Merge tag 'asm-generic-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd...
[deliverable/linux.git] / fs / nilfs2 / the_nilfs.h
index d01ead1bea9a738a5268908fe321eed19af3cc07..79369fd6b13bcb8ba73198887f004fbf8536b663 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- * Written by Ryusuke Konishi <ryusuke@osrg.net>
+ * Written by Ryusuke Konishi.
  *
  */
 
@@ -46,6 +42,7 @@ enum {
 /**
  * struct the_nilfs - struct to supervise multiple nilfs mount points
  * @ns_flags: flags
+ * @ns_flushed_device: flag indicating if all volatile data was flushed
  * @ns_bdev: block device
  * @ns_sem: semaphore for shared states
  * @ns_snapshot_mount_mutex: mutex to protect snapshot mounts
@@ -103,6 +100,7 @@ enum {
  */
 struct the_nilfs {
        unsigned long           ns_flags;
+       int                     ns_flushed_device;
 
        struct block_device    *ns_bdev;
        struct rw_semaphore     ns_sem;
@@ -116,10 +114,10 @@ struct the_nilfs {
        struct buffer_head     *ns_sbh[2];
        struct nilfs_super_block *ns_sbp[2];
        time_t                  ns_sbwtime;
-       unsigned                ns_sbwcount;
-       unsigned                ns_sbsize;
-       unsigned                ns_mount_state;
-       unsigned                ns_sb_update_freq;
+       unsigned int            ns_sbwcount;
+       unsigned int            ns_sbsize;
+       unsigned int            ns_mount_state;
+       unsigned int            ns_sb_update_freq;
 
        /*
         * Following fields are dedicated to a writable FS-instance.
@@ -224,15 +222,14 @@ THE_NILFS_FNS(SB_DIRTY, sb_dirty)
  * Mount option operations
  */
 #define nilfs_clear_opt(nilfs, opt)  \
-       do { (nilfs)->ns_mount_opt &= ~NILFS_MOUNT_##opt; } while (0)
+       ((nilfs)->ns_mount_opt &= ~NILFS_MOUNT_##opt)
 #define nilfs_set_opt(nilfs, opt)  \
-       do { (nilfs)->ns_mount_opt |= NILFS_MOUNT_##opt; } while (0)
+       ((nilfs)->ns_mount_opt |= NILFS_MOUNT_##opt)
 #define nilfs_test_opt(nilfs, opt) ((nilfs)->ns_mount_opt & NILFS_MOUNT_##opt)
 #define nilfs_write_opt(nilfs, mask, opt)                              \
-       do { (nilfs)->ns_mount_opt =                                    \
+       ((nilfs)->ns_mount_opt =                                        \
                (((nilfs)->ns_mount_opt & ~NILFS_MOUNT_##mask) |        \
-                NILFS_MOUNT_##opt);                                    \
-       } while (0)
+                NILFS_MOUNT_##opt))                                    \
 
 /**
  * struct nilfs_root - nilfs root object
@@ -271,6 +268,7 @@ struct nilfs_root {
 static inline int nilfs_sb_need_update(struct the_nilfs *nilfs)
 {
        u64 t = get_seconds();
+
        return t < nilfs->ns_sbwtime ||
                t > nilfs->ns_sbwtime + nilfs->ns_sb_update_freq;
 }
@@ -278,6 +276,7 @@ static inline int nilfs_sb_need_update(struct the_nilfs *nilfs)
 static inline int nilfs_sb_will_flip(struct the_nilfs *nilfs)
 {
        int flip_bits = nilfs->ns_sbwcount & 0x0FL;
+
        return (flip_bits != 0x08 && flip_bits != 0x0F);
 }
 
@@ -306,7 +305,7 @@ static inline void nilfs_get_root(struct nilfs_root *root)
 
 static inline int nilfs_valid_fs(struct the_nilfs *nilfs)
 {
-       unsigned valid_fs;
+       unsigned int valid_fs;
 
        down_read(&nilfs->ns_sem);
        valid_fs = (nilfs->ns_mount_state & NILFS_VALID_FS);
@@ -371,4 +370,24 @@ static inline int nilfs_segment_is_active(struct the_nilfs *nilfs, __u64 n)
        return n == nilfs->ns_segnum || n == nilfs->ns_nextnum;
 }
 
+static inline int nilfs_flush_device(struct the_nilfs *nilfs)
+{
+       int err;
+
+       if (!nilfs_test_opt(nilfs, BARRIER) || nilfs->ns_flushed_device)
+               return 0;
+
+       nilfs->ns_flushed_device = 1;
+       /*
+        * the store to ns_flushed_device must not be reordered after
+        * blkdev_issue_flush().
+        */
+       smp_wmb();
+
+       err = blkdev_issue_flush(nilfs->ns_bdev, GFP_KERNEL, NULL);
+       if (err != -EIO)
+               err = 0;
+       return err;
+}
+
 #endif /* _THE_NILFS_H */
This page took 0.029741 seconds and 5 git commands to generate.