diff -urp Paragon_NTFS_HFS_Linux_8.5.005_Express.orig/ifslinux/ufsdvfs.c Paragon_NTFS_HFS_Linux_8.5.005_Express/ifslinux/ufsdvfs.c
--- Paragon_NTFS_HFS_Linux_8.5.005_Express.orig/ifslinux/ufsdvfs.c	2011-05-30 03:59:42.000000000 -0700
+++ Paragon_NTFS_HFS_Linux_8.5.005_Express/ifslinux/ufsdvfs.c	2012-11-13 19:39:44.955393554 -0800
@@ -54,7 +54,11 @@ static const char s_FileVer[] = "$Id: uf
 #include <linux/vmalloc.h>
 #include <linux/nls.h>
 #include <asm/uaccess.h>
+#ifdef HAVE_UNLOCKED_IOCTL
+#include <linux/mutex.h>
+#else
 #include <linux/smp_lock.h>
+#endif
 #include <linux/mm.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
@@ -125,13 +129,6 @@ static const char s_FileVer[] = "$Id: uf
   #include <linux/fs_struct.h>
 #endif
 
-#if defined CONFIG_FS_POSIX_ACL \
-  && (defined HAVE_DECL_POSIX_ACL_FROM_XATTR && HAVE_DECL_POSIX_ACL_FROM_XATTR) \
-  && !defined UFSD_DISABLE_UGM
-  #include <linux/posix_acl_xattr.h>
-  #define UFSD_USE_XATTR              "Include code to support xattr and acl"
-#endif
-
 //
 // Default trace level for many functions in this module
 //
@@ -301,10 +298,6 @@ typedef struct usuper {
     UINT64            MaxBlock;
     UINT64            Eod;          // End of directory
     UFSD_VOLUME*      Ufsd;
-#if defined HAVE_DECL_FST_GETSB_V2 && HAVE_DECL_FST_GETSB_V2
-    struct vfsmount*  VfsMnt;
-    char              MntBuffer[32];
-#endif
     struct mutex      ApiMutex;
     mount_options     options;
 #ifdef UFSD_USE_XATTR
@@ -1120,7 +1113,6 @@ UfsdWaitOnIo(
     IN OUT struct UfsdBioWait*  wc
     )
 {
-  blk_run_address_space( sb->s_bdev->bd_inode->i_mapping );
   UfsdBioWaitDec( wc, 1 );
 
   wait_for_completion( &wc->io_complete );
@@ -1954,7 +1946,7 @@ LazyOpen(
   ASSERT( i->i_ino == Info.Id );
 
   if ( !Info.is_dir ) {
-    i->i_nlink  = Info.link_count;
+    set_nlink(i, Info.link_count);
     u->sparse   = Info.is_sparse;
     u->compr    = Info.is_compr;
     u->xattr    = Info.is_xattr;
@@ -2597,7 +2589,7 @@ ufsd_create_or_open (
     IN UFSD_FILE*           lnk,
     IN OUT struct dentry*   de,
     IN int                  create,
-    IN int                  mode,
+    IN umode_t              mode,
     OUT struct inode**      inode,
     IN const void*          data,
     IN int                  data_len
@@ -2621,10 +2613,8 @@ static int
 ufsd_create(
     IN struct inode*   dir,
     IN struct dentry*  de,
-    IN int             mode
-#if defined HAVE_DECL_INOP_CREATE_V2 && HAVE_DECL_INOP_CREATE_V2
-    , struct nameidata * nd  __attribute__((__unused__))
-#endif
+    IN umode_t         mode,
+    IN bool            excl
     )
 {
   struct inode* i = NULL;
@@ -2646,7 +2636,7 @@ static int
 ufsd_mkdir(
     IN struct inode*  dir,
     IN struct dentry* de,
-    IN int            mode
+    IN umode_t        mode
     )
 {
   struct inode* i = NULL;
@@ -2714,7 +2704,7 @@ ufsd_unlink(
   }
 
   if ( NULL == sname ) {
-    i->i_nlink -= 1;
+    set_nlink(i, i->i_nlink - 1);
 
     // Mark dir as requiring resync.
     dir->i_version += 1;
@@ -2729,13 +2719,11 @@ ufsd_unlink(
 #ifdef UFSD_COUNT_CONTAINED
   if ( S_ISDIR( i->i_mode ) ) {
     ASSERT(dir->i_nlink > 0);
-    dir->i_nlink -= 1;
+    set_nlink(dir, dir->i_nlink - 1);
     mark_inode_dirty( dir );
   }
 #endif
 
-  i->i_sb->s_dirt = 1;
-
   DebugTrace(-1, Dbg, ("unlink -> %d\n", 0));
   return 0;
 }
@@ -3556,7 +3544,6 @@ ufsd_rename(
   TIMESPEC_SECONDS( &odir->i_ctime ) = TIMESPEC_SECONDS( &odir->i_mtime ) = get_seconds();
   mark_inode_dirty( odir );
   mark_inode_dirty( ndir );
-  odir->i_sb->s_dirt = 1;
   odir->i_size   = UFSDAPI_GetDirSize( UFSD_FH( odir ) );
   odir->i_blocks = odir->i_size >> 9;
 
@@ -3570,8 +3557,8 @@ ufsd_rename(
 #ifdef UFSD_COUNT_CONTAINED
     if ( S_ISDIR( ode->d_inode->i_mode ) ) {
       ASSERT(odir->i_nlink > 0);
-      odir->i_nlink -= 1;
-      ndir->i_nlink += 1;
+      set_nlink(odir, odir->i_nlink - 1);
+      set_nlink(ndir, ndir->i_nlink + 1);
     }
 #endif
   }
@@ -3838,7 +3825,7 @@ ufsd_set_acl(
   switch( type ) {
     case ACL_TYPE_ACCESS:
       if ( acl ) {
-        mode_t mode = i->i_mode;
+        umode_t mode = i->i_mode;
         err = posix_acl_equiv_mode( acl, &mode );
         if ( err < 0 )
           return err;
@@ -3947,7 +3934,7 @@ ufsd_permission(
     IN unsigned int   flag
     )
 {
-  return generic_permission( i, mask, flag, ufsd_check_acl );
+  return generic_permission( i, mask );
 }
 #else
 ///////////////////////////////////////////////////////////
@@ -3964,7 +3951,7 @@ ufsd_permission(
 #endif
     )
 {
-  return generic_permission( i, mask, ufsd_check_acl );
+  return generic_permission( i, mask );
 }
 #endif
 
@@ -3994,7 +3981,7 @@ ufsd_init_acl(
 
   if ( UFSD_SB( i->i_sb )->options.acl && NULL != acl ) {
     struct posix_acl* clone;
-    mode_t mode;
+    umode_t mode;
 
     if ( S_ISDIR(i->i_mode) ) {
       err = ufsd_set_acl( i, ACL_TYPE_DEFAULT, acl, 1 );
@@ -4563,10 +4550,8 @@ STATIC_CONST struct xattr_handler* ufsd_
 static struct dentry*
 ufsd_lookup(
     IN struct inode*  dir,
-    IN struct dentry* de
-#if defined HAVE_DECL_INOP_LOOKUP_V2 && HAVE_DECL_INOP_LOOKUP_V2
-  , IN struct nameidata * nd  __attribute__((__unused__))
-#endif
+    IN struct dentry* de,
+    IN unsigned int flags
     )
 {
   struct inode* i = NULL;
@@ -4625,8 +4610,7 @@ ufsd_link(
 
     d_instantiate( de, i );
 
-    i->i_nlink       += 1;
-    dir->i_sb->s_dirt = 1;
+    set_nlink(i, i->i_nlink       + 1);
   }
 
   DebugTrace(-1, Dbg, ("link -> %d\n", err ));
@@ -4647,7 +4631,7 @@ static int
 ufsd_mknod(
     IN struct inode*  dir,
     IN struct dentry* de,
-    IN int            mode,
+    IN umode_t        mode,
     IN dev_t          rdev
     );
 
@@ -4696,7 +4680,7 @@ static int
 ufsd_mknod(
     IN struct inode*  dir,
     IN struct dentry* de,
-    IN int            mode,
+    IN umode_t        mode,
     IN dev_t          rdev
     )
 {
@@ -5622,54 +5606,6 @@ ufsd_readlink_hlp(
     p += 1;
   len = (int)(p-kaddr);
 
-#if defined HAVE_DECL_FST_GETSB_V2 && HAVE_DECL_FST_GETSB_V2
-  //
-  // Assume that link points to the same volume
-  // and convert strings
-  // C:\\Users => /mnt/ntfs/Users
-  //
-  if ( len > 3
-    && 'a' <= (kaddr[0] | 0x20)
-    && (kaddr[0] | 0x20) <= 'z'
-    && ':' == kaddr[1]
-    && '\\' == kaddr[2]
-    && NULL != sbi->VfsMnt ) {
-
-    char* MntPath;
-#if defined HAVE_DECL_D_PATH_V1 && HAVE_DECL_D_PATH_V1
-    MntPath       = d_path( sbi->VfsMnt->mnt_root, sbi->VfsMnt, sbi->MntBuffer, sizeof(sbi->MntBuffer) - 1 );
-#elif defined HAVE_DECL_D_PATH_V2 && HAVE_DECL_D_PATH_V2
-    struct path path;
-    path.dentry   = sbi->VfsMnt->mnt_root;
-    path.mnt      = sbi->VfsMnt;
-    MntPath       = d_path( &path, sbi->MntBuffer, sizeof(sbi->MntBuffer) - 1 );
-#else
-#error d_path unknown
-#endif
-
-    if ( !IS_ERR(MntPath) ) {
-//      DebugTrace(0, Dbg,("mount path %s\n", MntPath ));
-      // Add last slash
-      int MntPathLen = strlen( MntPath );
-      MntPath[MntPathLen++] = '/';
-
-      if ( MntPathLen + len - 3 < buflen ) {
-        p = kaddr + MntPathLen;
-        memmove( p, kaddr + 3, len - 3 );
-        memcpy( kaddr, MntPath, MntPathLen );
-        len += MntPathLen - 3;
-        // Convert slashes
-        l = kaddr + len;
-        while( ++p < l ){
-          if ( '\\' == *p )
-            *p = '/';
-        }
-        *p = 0;
-      }
-    }
-  }
-#endif
-
   return len;
 }
 #endif
@@ -7702,7 +7638,7 @@ ufsd_da_write_begin(
   // start pushing delalloc when 1/2 of free blocks are dirty.
   //
   if ( fBlocks < 2 * dBlocks )
-    writeback_inodes_sb_if_idle( i->i_sb );
+    writeback_inodes_sb_if_idle( i->i_sb, WB_REASON_BACKGROUND );
 #endif
 
   ProfileEnter( sbi, da_write_begin );
@@ -7937,8 +7873,8 @@ ufsd_direct_IO(
   DebugTrace(+1, Dbg, ("direct_IO: %s, %llx, %lu s=%llx,%llx\n",
               (rw&WRITE)? "w":"r", offset, nr_segs, (UINT64)(UFSD_U( i )->mmu), i->i_size ));
 
-  ret = blockdev_direct_IO( rw, iocb, i, i->i_sb->s_bdev, iov,
-                            offset, nr_segs, ufsd_get_block_io, NULL );
+  ret = blockdev_direct_IO( rw, iocb, i, iov,
+                            offset, nr_segs, ufsd_get_block_io );
 
   if ( ret > 0 ) {
     DebugTrace(-1, Dbg, ("direct_IO -> %Zx\n", ret ));
@@ -7983,7 +7919,6 @@ ufsd_direct_IO(
 STATIC_CONST struct address_space_operations ufsd_aops = {
   .writepage      = ufsd_writepage,
   .readpage       = ufsd_readpage,
-  .sync_page      = block_sync_page,
 #if defined HAVE_STRUCT_ADDRESS_SPACE_OPERATIONS_WRITE_BEGIN && HAVE_STRUCT_ADDRESS_SPACE_OPERATIONS_WRITE_BEGIN
   .write_begin    = ufsd_write_begin,
   .write_end      = ufsd_write_end,
@@ -8013,7 +7948,6 @@ STATIC_CONST struct address_space_operat
 STATIC_CONST struct address_space_operations ufsd_da_aops = {
   .writepage      = ufsd_da_writepage,
   .readpage       = ufsd_readpage,
-  .sync_page      = block_sync_page,
   .write_begin    = ufsd_da_write_begin,
   .write_end      = ufsd_da_write_end,
   .readpages      = ufsd_readpages,
@@ -8287,9 +8221,9 @@ ufsd_read_inode2(
     // in enumeration.
     ASSERT( 1 == p->Info.link_count ); // Usually a hard link to directories are disabled
 #ifdef UFSD_COUNT_CONTAINED
-    i->i_nlink  = p->Info.link_count + p->subdir_count + 1;
+    set_nlink(i, p->Info.link_count + p->subdir_count + 1);
 #else
-    i->i_nlink  = 1;
+    set_nlink(i, 1);
 #endif
     if ( 0 == i->i_size ) {
       i->i_size   = sb->s_blocksize; // fake. Required to be non-zero.
@@ -8299,7 +8233,7 @@ ufsd_read_inode2(
     i->i_fop  = &ufsd_dir_operations;
     i->i_mode |= S_IFDIR;
   } else {
-    i->i_nlink  = p->Info.link_count;
+    set_nlink(i, p->Info.link_count);
     i->i_op     = &ufsd_file_inode_operations;
     i->i_fop    = &ufsd_file_operations;
 #ifdef UFSD_DELAY_ALLOC
@@ -8355,7 +8289,7 @@ ufsd_create_or_open(
     IN UFSD_FILE*           lnk,
     IN OUT struct dentry*   de,
     IN int                  create,
-    IN int                  mode,
+    IN umode_t              mode,
     OUT struct inode**      inode,
     IN const void*          data,
     IN int                  data_len
@@ -8463,7 +8397,7 @@ ufsd_create_or_open(
       ASSERT( NULL != dir );
 #ifdef UFSD_COUNT_CONTAINED
       if ( S_ISDIR ( i->i_mode ) )
-        dir->i_nlink += 1;
+        set_nlink(dir, dir->i_nlink + 1);
 #endif
       TIMESPEC_SECONDS( &dir->i_mtime ) = TIMESPEC_SECONDS( &dir->i_ctime ) = get_seconds();
       // Mark dir as requiring resync.
@@ -8473,7 +8407,6 @@ ufsd_create_or_open(
 
       mark_inode_dirty( dir );
 //      mark_inode_dirty( i );
-      dir->i_sb->s_dirt = 1;
 
       if ( lnk ){
         i->i_ctime = dir->i_ctime;
@@ -9006,41 +8939,6 @@ int ufsd_write_inode(
 }
 
 
-///////////////////////////////////////////////////////////
-// ufsd_sync_volume
-//
-// super_operations::write_super
-///////////////////////////////////////////////////////////
-static void
-ufsd_sync_volume(
-    IN struct super_block * sb
-    )
-{
-  usuper* sbi = UFSD_SB( sb );
-  DebugTrace(+1, Dbg, ("sync_volume: %p (%s)\n", sb, UFSD_BdGetName(sb)));
-
-  sb->s_dirt = 0; // reset dirty flag to not get here anymore.
-
-  if ( !TryLockUfsd( sbi ) ){
-
-    UFSDAPI_VolumeFlush( sbi->Ufsd );
-    UnlockUfsd( sbi );
-
-    sync_blockdev( sb_dev(sb) );
-
-  } else {
-
-    //
-    // Do volume flush later
-    //
-    mutex_lock( &sbi->ddt_mutex );
-    sbi->VFlush = 1;
-    mutex_unlock( &sbi->ddt_mutex );
-  }
-
-  DebugTrace(-1, Dbg, ("sync_volume ->\n"));
-}
-
 #if defined HAVE_DECL_KSTATFS && HAVE_DECL_KSTATFS
 #define kstatfs statfs
 #endif
@@ -9250,7 +9148,7 @@ ufsd_evict_inode(
 #if defined HAVE_STRUCT_SUPER_OPERATIONS_EVICT_INODE && HAVE_STRUCT_SUPER_OPERATIONS_EVICT_INODE
   if ( i->i_data.nrpages )
     truncate_inode_pages( &i->i_data, 0 );
-  end_writeback( i );
+  clear_inode( i );
 #else
   #define evict_inode clear_inode
 #endif
@@ -9323,10 +9221,10 @@ ufsd_evict_inode(
 static int
 ufsd_show_options(
     IN struct seq_file* seq,
-    IN struct vfsmount* vfs
+    IN struct dentry* root
     )
 {
-  usuper* sbi = UFSD_SB( vfs->mnt_sb );
+  usuper* sbi = UFSD_SB( root->d_sb );
   mount_options* opts = &sbi->options;
 //  DEBUG_ONLY( char* buf = seq->buf + seq->count; )
 
@@ -9400,7 +9298,6 @@ STATIC_CONST struct super_operations ufs
   .put_super      = ufsd_put_super,
   .statfs         = ufsd_statfs,
   .remount_fs     = ufsd_remount,
-  .write_super    = ufsd_sync_volume,
   .write_inode    = ufsd_write_inode,
   .evict_inode    = ufsd_evict_inode,
   .show_options   = ufsd_show_options,
@@ -10524,7 +10421,7 @@ ufsd_read_super(
     goto Exit;
   }
 
-  sb->s_root = d_alloc_root( i );
+  sb->s_root = d_make_root( i );
 
   if ( NULL == sb->s_root ) {
     iput( i );
@@ -10539,7 +10436,7 @@ ufsd_read_super(
 #ifdef UFSD_DELAY_ALLOC
   // Should we call atomic_set( &sbi->DirtyBlocks, 0 )
   ASSERT( 0 == atomic_long_read( &sbi->DirtyBlocks ) );
-  atomic_set( &sbi->FreeBlocks, Info.BlocksFree );
+  atomic_long_set( &sbi->FreeBlocks, Info.BlocksFree );
 
   DEBUG_ONLY( if ( Info.BlocksFree < UFSD_RED_ZONE ) sbi->DoNotTraceNoSpc = 1; )
 
@@ -10592,55 +10489,27 @@ static int ufsd_read_super2( struct supe
   return ufsd_read_super( sb, data, silent ) ? 0 : -EINVAL;
 }
 
-#if defined HAVE_DECL_FST_GETSB_V2 && HAVE_DECL_FST_GETSB_V2
-
 ///////////////////////////////////////////////////////////
 // ufsd_get_sb
 //
 // 2,6,18+
 ///////////////////////////////////////////////////////////
-static int
-ufsd_get_sb(
-    IN struct file_system_type* fs_type,
-    IN int                      flags,
-    IN const char*              dev_name,
-    IN void*                    data,
-    IN struct vfsmount*         mnt
-    )
-{
-  int err = get_sb_bdev( fs_type, flags, dev_name, data, ufsd_read_super2, mnt );
-  if ( 0 == err ) {
-    // Save mount path to correct ntfs symlinks (see ufsd_readlink_hlp)
-    usuper* sbi = UFSD_SB( mnt->mnt_sb );
-    sbi->VfsMnt = mnt;
-  }
-  return err;
-}
-
-#else
-
-///////////////////////////////////////////////////////////
-// ufsd_get_sb
-//
-// 2,6,18-
-///////////////////////////////////////////////////////////
-static struct super_block *
-ufsd_get_sb(
+static struct dentry *
+ufsd_mount(
     IN struct file_system_type* fs_type,
     IN int                      flags,
     IN const char*              dev_name,
     IN void*                    data
     )
 {
-  return get_sb_bdev(fs_type, flags, dev_name, data, ufsd_read_super2 );
+  struct dentry * root = mount_bdev( fs_type, flags, dev_name, data, ufsd_read_super2 );
+  return root;
 }
 
-#endif //defined HAVE_DECL_FST_GETSB_V2 && HAVE_DECL_FST_GETSB_V2
-
 static struct file_system_type ufsd_fs_type = {
     .owner      = THIS_MODULE,
     .name       = QUOTED_UFSD_DEVICE,
-    .get_sb     = ufsd_get_sb,
+    .mount      = ufsd_mount,
     .kill_sb    = kill_block_super,
     .fs_flags   = FS_REQUIRES_DEV,
 };
