aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/ntfs.txt268
-rw-r--r--fs/ntfs/Makefile2
-rw-r--r--fs/ntfs/aops.c163
-rw-r--r--fs/ntfs/inode.c19
-rw-r--r--fs/ntfs/ntfs.h8
5 files changed, 167 insertions, 293 deletions
diff --git a/Documentation/filesystems/ntfs.txt b/Documentation/filesystems/ntfs.txt
index 61947facfc07..553f10d03076 100644
--- a/Documentation/filesystems/ntfs.txt
+++ b/Documentation/filesystems/ntfs.txt
@@ -14,7 +14,6 @@ Table of contents
14 - The Device-Mapper driver 14 - The Device-Mapper driver
15 - The Software RAID / MD driver 15 - The Software RAID / MD driver
16 - Limitations when using the MD driver 16 - Limitations when using the MD driver
17- ChangeLog
18 17
19 18
20Overview 19Overview
@@ -450,270 +449,3 @@ number of sectors BEFORE attempting to use it. You have been warned!
450 449
451Even better is to simply use the Device-Mapper for linear raid and then you do 450Even better is to simply use the Device-Mapper for linear raid and then you do
452not have this problem with odd numbers of sectors. 451not have this problem with odd numbers of sectors.
453
454
455ChangeLog
456=========
457
4582.1.30:
459 - Fix writev() (it kept writing the first segment over and over again
460 instead of moving onto subsequent segments).
461 - Fix crash in ntfs_mft_record_alloc() when mapping the new extent mft
462 record failed.
4632.1.29:
464 - Fix a deadlock when mounting read-write.
4652.1.28:
466 - Fix a deadlock.
4672.1.27:
468 - Implement page migration support so the kernel can move memory used
469 by NTFS files and directories around for management purposes.
470 - Add support for writing to sparse files created with Windows XP SP2.
471 - Many minor improvements and bug fixes.
4722.1.26:
473 - Implement support for sector sizes above 512 bytes (up to the maximum
474 supported by NTFS which is 4096 bytes).
475 - Enhance support for NTFS volumes which were supported by Windows but
476 not by Linux due to invalid attribute list attribute flags.
477 - A few minor updates and bug fixes.
4782.1.25:
479 - Write support is now extended with write(2) being able to both
480 overwrite existing file data and to extend files. Also, if a write
481 to a sparse region occurs, write(2) will fill in the hole. Note,
482 mmap(2) based writes still do not support writing into holes or
483 writing beyond the initialized size.
484 - Write support has a new feature and that is that truncate(2) and
485 open(2) with O_TRUNC are now implemented thus files can be both made
486 smaller and larger.
487 - Note: Both write(2) and truncate(2)/open(2) with O_TRUNC still have
488 limitations in that they
489 - only provide limited support for highly fragmented files.
490 - only work on regular, i.e. uncompressed and unencrypted files.
491 - never create sparse files although this will change once directory
492 operations are implemented.
493 - Lots of bug fixes and enhancements across the board.
4942.1.24:
495 - Support journals ($LogFile) which have been modified by chkdsk. This
496 means users can boot into Windows after we marked the volume dirty.
497 The Windows boot will run chkdsk and then reboot. The user can then
498 immediately boot into Linux rather than having to do a full Windows
499 boot first before rebooting into Linux and we will recognize such a
500 journal and empty it as it is clean by definition.
501 - Support journals ($LogFile) with only one restart page as well as
502 journals with two different restart pages. We sanity check both and
503 either use the only sane one or the more recent one of the two in the
504 case that both are valid.
505 - Lots of bug fixes and enhancements across the board.
5062.1.23:
507 - Stamp the user space journal, aka transaction log, aka $UsnJrnl, if
508 it is present and active thus telling Windows and applications using
509 the transaction log that changes can have happened on the volume
510 which are not recorded in $UsnJrnl.
511 - Detect the case when Windows has been hibernated (suspended to disk)
512 and if this is the case do not allow (re)mounting read-write to
513 prevent data corruption when you boot back into the suspended
514 Windows session.
515 - Implement extension of resident files using the normal file write
516 code paths, i.e. most very small files can be extended to be a little
517 bit bigger but not by much.
518 - Add new mount option "disable_sparse". (See list of mount options
519 above for details.)
520 - Improve handling of ntfs volumes with errors and strange boot sectors
521 in particular.
522 - Fix various bugs including a nasty deadlock that appeared in recent
523 kernels (around 2.6.11-2.6.12 timeframe).
5242.1.22:
525 - Improve handling of ntfs volumes with errors.
526 - Fix various bugs and race conditions.
5272.1.21:
528 - Fix several race conditions and various other bugs.
529 - Many internal cleanups, code reorganization, optimizations, and mft
530 and index record writing code rewritten to fit in with the changes.
531 - Update Documentation/filesystems/ntfs.txt with instructions on how to
532 use the Device-Mapper driver with NTFS ftdisk/LDM raid.
5332.1.20:
534 - Fix two stupid bugs introduced in 2.1.18 release.
5352.1.19:
536 - Minor bugfix in handling of the default upcase table.
537 - Many internal cleanups and improvements. Many thanks to Linus
538 Torvalds and Al Viro for the help and advice with the sparse
539 annotations and cleanups.
5402.1.18:
541 - Fix scheduling latencies at mount time. (Ingo Molnar)
542 - Fix endianness bug in a little traversed portion of the attribute
543 lookup code.
5442.1.17:
545 - Fix bugs in mount time error code paths.
5462.1.16:
547 - Implement access time updates (including mtime and ctime).
548 - Implement fsync(2), fdatasync(2), and msync(2) system calls.
549 - Enable the readv(2) and writev(2) system calls.
550 - Enable access via the asynchronous io (aio) API by adding support for
551 the aio_read(3) and aio_write(3) functions.
5522.1.15:
553 - Invalidate quotas when (re)mounting read-write.
554 NOTE: This now only leave user space journalling on the side. (See
555 note for version 2.1.13, below.)
5562.1.14:
557 - Fix an NFSd caused deadlock reported by several users.
5582.1.13:
559 - Implement writing of inodes (access time updates are not implemented
560 yet so mounting with -o noatime,nodiratime is enforced).
561 - Enable writing out of resident files so you can now overwrite any
562 uncompressed, unencrypted, nonsparse file as long as you do not
563 change the file size.
564 - Add housekeeping of ntfs system files so that ntfsfix no longer needs
565 to be run after writing to an NTFS volume.
566 NOTE: This still leaves quota tracking and user space journalling on
567 the side but they should not cause data corruption. In the worst
568 case the charged quotas will be out of date ($Quota) and some
569 userspace applications might get confused due to the out of date
570 userspace journal ($UsnJrnl).
5712.1.12:
572 - Fix the second fix to the decompression engine from the 2.1.9 release
573 and some further internals cleanups.
5742.1.11:
575 - Driver internal cleanups.
5762.1.10:
577 - Force read-only (re)mounting of volumes with unsupported volume
578 flags and various cleanups.
5792.1.9:
580 - Fix two bugs in handling of corner cases in the decompression engine.
5812.1.8:
582 - Read the $MFT mirror and compare it to the $MFT and if the two do not
583 match, force a read-only mount and do not allow read-write remounts.
584 - Read and parse the $LogFile journal and if it indicates that the
585 volume was not shutdown cleanly, force a read-only mount and do not
586 allow read-write remounts. If the $LogFile indicates a clean
587 shutdown and a read-write (re)mount is requested, empty $LogFile to
588 ensure that Windows cannot cause data corruption by replaying a stale
589 journal after Linux has written to the volume.
590 - Improve time handling so that the NTFS time is fully preserved when
591 converted to kernel time and only up to 99 nano-seconds are lost when
592 kernel time is converted to NTFS time.
5932.1.7:
594 - Enable NFS exporting of mounted NTFS volumes.
5952.1.6:
596 - Fix minor bug in handling of compressed directories that fixes the
597 erroneous "du" and "stat" output people reported.
5982.1.5:
599 - Minor bug fix in attribute list attribute handling that fixes the
600 I/O errors on "ls" of certain fragmented files found by at least two
601 people running Windows XP.
6022.1.4:
603 - Minor update allowing compilation with all gcc versions (well, the
604 ones the kernel can be compiled with anyway).
6052.1.3:
606 - Major bug fixes for reading files and volumes in corner cases which
607 were being hit by Windows 2k/XP users.
6082.1.2:
609 - Major bug fixes alleviating the hangs in statfs experienced by some
610 users.
6112.1.1:
612 - Update handling of compressed files so people no longer get the
613 frequently reported warning messages about initialized_size !=
614 data_size.
6152.1.0:
616 - Add configuration option for developmental write support.
617 - Initial implementation of file overwriting. (Writes to resident files
618 are not written out to disk yet, so avoid writing to files smaller
619 than about 1kiB.)
620 - Intercept/abort changes in file size as they are not implemented yet.
6212.0.25:
622 - Minor bugfixes in error code paths and small cleanups.
6232.0.24:
624 - Small internal cleanups.
625 - Support for sendfile system call. (Christoph Hellwig)
6262.0.23:
627 - Massive internal locking changes to mft record locking. Fixes
628 various race conditions and deadlocks.
629 - Fix ntfs over loopback for compressed files by adding an
630 optimization barrier. (gcc was screwing up otherwise ?)
631 Thanks go to Christoph Hellwig for pointing these two out:
632 - Remove now unused function fs/ntfs/malloc.h::vmalloc_nofs().
633 - Fix ntfs_free() for ia64 and parisc.
6342.0.22:
635 - Small internal cleanups.
6362.0.21:
637 These only affect 32-bit architectures:
638 - Check for, and refuse to mount too large volumes (maximum is 2TiB).
639 - Check for, and refuse to open too large files and directories
640 (maximum is 16TiB).
6412.0.20:
642 - Support non-resident directory index bitmaps. This means we now cope
643 with huge directories without problems.
644 - Fix a page leak that manifested itself in some cases when reading
645 directory contents.
646 - Internal cleanups.
6472.0.19:
648 - Fix race condition and improvements in block i/o interface.
649 - Optimization when reading compressed files.
6502.0.18:
651 - Fix race condition in reading of compressed files.
6522.0.17:
653 - Cleanups and optimizations.
6542.0.16:
655 - Fix stupid bug introduced in 2.0.15 in new attribute inode API.
656 - Big internal cleanup replacing the mftbmp access hacks by using the
657 new attribute inode API instead.
6582.0.15:
659 - Bug fix in parsing of remount options.
660 - Internal changes implementing attribute (fake) inodes allowing all
661 attribute i/o to go via the page cache and to use all the normal
662 vfs/mm functionality.
6632.0.14:
664 - Internal changes improving run list merging code and minor locking
665 change to not rely on BKL in ntfs_statfs().
6662.0.13:
667 - Internal changes towards using iget5_locked() in preparation for
668 fake inodes and small cleanups to ntfs_volume structure.
6692.0.12:
670 - Internal cleanups in address space operations made possible by the
671 changes introduced in the previous release.
6722.0.11:
673 - Internal updates and cleanups introducing the first step towards
674 fake inode based attribute i/o.
6752.0.10:
676 - Microsoft says that the maximum number of inodes is 2^32 - 1. Update
677 the driver accordingly to only use 32-bits to store inode numbers on
678 32-bit architectures. This improves the speed of the driver a little.
6792.0.9:
680 - Change decompression engine to use a single buffer. This should not
681 affect performance except perhaps on the most heavy i/o on SMP
682 systems when accessing multiple compressed files from multiple
683 devices simultaneously.
684 - Minor updates and cleanups.
6852.0.8:
686 - Remove now obsolete show_inodes and posix mount option(s).
687 - Restore show_sys_files mount option.
688 - Add new mount option case_sensitive, to determine if the driver
689 treats file names as case sensitive or not.
690 - Mostly drop support for short file names (for backwards compatibility
691 we only support accessing files via their short file name if one
692 exists).
693 - Fix dcache aliasing issues wrt short/long file names.
694 - Cleanups and minor fixes.
6952.0.7:
696 - Just cleanups.
6972.0.6:
698 - Major bugfix to make compatible with other kernel changes. This fixes
699 the hangs/oopses on umount.
700 - Locking cleanup in directory operations (remove BKL usage).
7012.0.5:
702 - Major buffer overflow bug fix.
703 - Minor cleanups and updates for kernel 2.5.12.
7042.0.4:
705 - Cleanups and updates for kernel 2.5.11.
7062.0.3:
707 - Small bug fixes, cleanups, and performance improvements.
7082.0.2:
709 - Use default fmask of 0177 so that files are no executable by default.
710 If you want owner executable files, just use fmask=0077.
711 - Update for kernel 2.5.9 but preserve backwards compatibility with
712 kernel 2.5.7.
713 - Minor bug fixes, cleanups, and updates.
7142.0.1:
715 - Minor updates, primarily set the executable bit by default on files
716 so they can be executed.
7172.0.0:
718 - Started ChangeLog.
719
diff --git a/fs/ntfs/Makefile b/fs/ntfs/Makefile
index 30206b238433..36ae529511c4 100644
--- a/fs/ntfs/Makefile
+++ b/fs/ntfs/Makefile
@@ -8,7 +8,7 @@ ntfs-y := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \
8 8
9ntfs-$(CONFIG_NTFS_RW) += bitmap.o lcnalloc.o logfile.o quota.o usnjrnl.o 9ntfs-$(CONFIG_NTFS_RW) += bitmap.o lcnalloc.o logfile.o quota.o usnjrnl.o
10 10
11ccflags-y := -DNTFS_VERSION=\"2.1.30\" 11ccflags-y := -DNTFS_VERSION=\"2.1.31\"
12ccflags-$(CONFIG_NTFS_DEBUG) += -DDEBUG 12ccflags-$(CONFIG_NTFS_DEBUG) += -DDEBUG
13ccflags-$(CONFIG_NTFS_RW) += -DNTFS_RW 13ccflags-$(CONFIG_NTFS_RW) += -DNTFS_RW
14 14
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index d267ea6aa1a0..7521e11db728 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -1,8 +1,7 @@
1/** 1/**
2 * aops.c - NTFS kernel address space operations and page cache handling. 2 * aops.c - NTFS kernel address space operations and page cache handling.
3 * Part of the Linux-NTFS project.
4 * 3 *
5 * Copyright (c) 2001-2007 Anton Altaparmakov 4 * Copyright (c) 2001-2014 Anton Altaparmakov and Tuxera Inc.
6 * Copyright (c) 2002 Richard Russon 5 * Copyright (c) 2002 Richard Russon
7 * 6 *
8 * This program/include file is free software; you can redistribute it and/or 7 * This program/include file is free software; you can redistribute it and/or
@@ -1539,16 +1538,157 @@ err_out:
1539#endif /* NTFS_RW */ 1538#endif /* NTFS_RW */
1540 1539
1541/** 1540/**
1542 * ntfs_aops - general address space operations for inodes and attributes 1541 * ntfs_bmap - map logical file block to physical device block
1542 * @mapping: address space mapping to which the block to be mapped belongs
1543 * @block: logical block to map to its physical device block
1544 *
1545 * For regular, non-resident files (i.e. not compressed and not encrypted), map
1546 * the logical @block belonging to the file described by the address space
1547 * mapping @mapping to its physical device block.
1548 *
1549 * The size of the block is equal to the @s_blocksize field of the super block
1550 * of the mounted file system which is guaranteed to be smaller than or equal
1551 * to the cluster size thus the block is guaranteed to fit entirely inside the
1552 * cluster which means we do not need to care how many contiguous bytes are
1553 * available after the beginning of the block.
1554 *
1555 * Return the physical device block if the mapping succeeded or 0 if the block
1556 * is sparse or there was an error.
1557 *
1558 * Note: This is a problem if someone tries to run bmap() on $Boot system file
1559 * as that really is in block zero but there is nothing we can do. bmap() is
1560 * just broken in that respect (just like it cannot distinguish sparse from
1561 * not available or error).
1543 */ 1562 */
1544const struct address_space_operations ntfs_aops = { 1563static sector_t ntfs_bmap(struct address_space *mapping, sector_t block)
1545 .readpage = ntfs_readpage, /* Fill page with data. */ 1564{
1565 s64 ofs, size;
1566 loff_t i_size;
1567 LCN lcn;
1568 unsigned long blocksize, flags;
1569 ntfs_inode *ni = NTFS_I(mapping->host);
1570 ntfs_volume *vol = ni->vol;
1571 unsigned delta;
1572 unsigned char blocksize_bits, cluster_size_shift;
1573
1574 ntfs_debug("Entering for mft_no 0x%lx, logical block 0x%llx.",
1575 ni->mft_no, (unsigned long long)block);
1576 if (ni->type != AT_DATA || !NInoNonResident(ni) || NInoEncrypted(ni)) {
1577 ntfs_error(vol->sb, "BMAP does not make sense for %s "
1578 "attributes, returning 0.",
1579 (ni->type != AT_DATA) ? "non-data" :
1580 (!NInoNonResident(ni) ? "resident" :
1581 "encrypted"));
1582 return 0;
1583 }
1584 /* None of these can happen. */
1585 BUG_ON(NInoCompressed(ni));
1586 BUG_ON(NInoMstProtected(ni));
1587 blocksize = vol->sb->s_blocksize;
1588 blocksize_bits = vol->sb->s_blocksize_bits;
1589 ofs = (s64)block << blocksize_bits;
1590 read_lock_irqsave(&ni->size_lock, flags);
1591 size = ni->initialized_size;
1592 i_size = i_size_read(VFS_I(ni));
1593 read_unlock_irqrestore(&ni->size_lock, flags);
1594 /*
1595 * If the offset is outside the initialized size or the block straddles
1596 * the initialized size then pretend it is a hole unless the
1597 * initialized size equals the file size.
1598 */
1599 if (unlikely(ofs >= size || (ofs + blocksize > size && size < i_size)))
1600 goto hole;
1601 cluster_size_shift = vol->cluster_size_bits;
1602 down_read(&ni->runlist.lock);
1603 lcn = ntfs_attr_vcn_to_lcn_nolock(ni, ofs >> cluster_size_shift, false);
1604 up_read(&ni->runlist.lock);
1605 if (unlikely(lcn < LCN_HOLE)) {
1606 /*
1607 * Step down to an integer to avoid gcc doing a long long
1608 * comparision in the switch when we know @lcn is between
1609 * LCN_HOLE and LCN_EIO (i.e. -1 to -5).
1610 *
1611 * Otherwise older gcc (at least on some architectures) will
1612 * try to use __cmpdi2() which is of course not available in
1613 * the kernel.
1614 */
1615 switch ((int)lcn) {
1616 case LCN_ENOENT:
1617 /*
1618 * If the offset is out of bounds then pretend it is a
1619 * hole.
1620 */
1621 goto hole;
1622 case LCN_ENOMEM:
1623 ntfs_error(vol->sb, "Not enough memory to complete "
1624 "mapping for inode 0x%lx. "
1625 "Returning 0.", ni->mft_no);
1626 break;
1627 default:
1628 ntfs_error(vol->sb, "Failed to complete mapping for "
1629 "inode 0x%lx. Run chkdsk. "
1630 "Returning 0.", ni->mft_no);
1631 break;
1632 }
1633 return 0;
1634 }
1635 if (lcn < 0) {
1636 /* It is a hole. */
1637hole:
1638 ntfs_debug("Done (returning hole).");
1639 return 0;
1640 }
1641 /*
1642 * The block is really allocated and fullfils all our criteria.
1643 * Convert the cluster to units of block size and return the result.
1644 */
1645 delta = ofs & vol->cluster_size_mask;
1646 if (unlikely(sizeof(block) < sizeof(lcn))) {
1647 block = lcn = ((lcn << cluster_size_shift) + delta) >>
1648 blocksize_bits;
1649 /* If the block number was truncated return 0. */
1650 if (unlikely(block != lcn)) {
1651 ntfs_error(vol->sb, "Physical block 0x%llx is too "
1652 "large to be returned, returning 0.",
1653 (long long)lcn);
1654 return 0;
1655 }
1656 } else
1657 block = ((lcn << cluster_size_shift) + delta) >>
1658 blocksize_bits;
1659 ntfs_debug("Done (returning block 0x%llx).", (unsigned long long)lcn);
1660 return block;
1661}
1662
1663/**
1664 * ntfs_normal_aops - address space operations for normal inodes and attributes
1665 *
1666 * Note these are not used for compressed or mst protected inodes and
1667 * attributes.
1668 */
1669const struct address_space_operations ntfs_normal_aops = {
1670 .readpage = ntfs_readpage,
1546#ifdef NTFS_RW 1671#ifdef NTFS_RW
1547 .writepage = ntfs_writepage, /* Write dirty page to disk. */ 1672 .writepage = ntfs_writepage,
1673 .set_page_dirty = __set_page_dirty_buffers,
1674#endif /* NTFS_RW */
1675 .bmap = ntfs_bmap,
1676 .migratepage = buffer_migrate_page,
1677 .is_partially_uptodate = block_is_partially_uptodate,
1678 .error_remove_page = generic_error_remove_page,
1679};
1680
1681/**
1682 * ntfs_compressed_aops - address space operations for compressed inodes
1683 */
1684const struct address_space_operations ntfs_compressed_aops = {
1685 .readpage = ntfs_readpage,
1686#ifdef NTFS_RW
1687 .writepage = ntfs_writepage,
1688 .set_page_dirty = __set_page_dirty_buffers,
1548#endif /* NTFS_RW */ 1689#endif /* NTFS_RW */
1549 .migratepage = buffer_migrate_page, /* Move a page cache page from 1690 .migratepage = buffer_migrate_page,
1550 one physical page to an 1691 .is_partially_uptodate = block_is_partially_uptodate,
1551 other. */
1552 .error_remove_page = generic_error_remove_page, 1692 .error_remove_page = generic_error_remove_page,
1553}; 1693};
1554 1694
@@ -1564,9 +1704,8 @@ const struct address_space_operations ntfs_mst_aops = {
1564 without touching the buffers 1704 without touching the buffers
1565 belonging to the page. */ 1705 belonging to the page. */
1566#endif /* NTFS_RW */ 1706#endif /* NTFS_RW */
1567 .migratepage = buffer_migrate_page, /* Move a page cache page from 1707 .migratepage = buffer_migrate_page,
1568 one physical page to an 1708 .is_partially_uptodate = block_is_partially_uptodate,
1569 other. */
1570 .error_remove_page = generic_error_remove_page, 1709 .error_remove_page = generic_error_remove_page,
1571}; 1710};
1572 1711
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index f47af5e6e230..898b9949d363 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -1,7 +1,7 @@
1/** 1/**
2 * inode.c - NTFS kernel inode handling. Part of the Linux-NTFS project. 2 * inode.c - NTFS kernel inode handling.
3 * 3 *
4 * Copyright (c) 2001-2007 Anton Altaparmakov 4 * Copyright (c) 2001-2014 Anton Altaparmakov and Tuxera Inc.
5 * 5 *
6 * This program/include file is free software; you can redistribute it and/or 6 * This program/include file is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published 7 * modify it under the terms of the GNU General Public License as published
@@ -1012,6 +1012,7 @@ skip_large_dir_stuff:
1012 /* Setup the operations for this inode. */ 1012 /* Setup the operations for this inode. */
1013 vi->i_op = &ntfs_dir_inode_ops; 1013 vi->i_op = &ntfs_dir_inode_ops;
1014 vi->i_fop = &ntfs_dir_ops; 1014 vi->i_fop = &ntfs_dir_ops;
1015 vi->i_mapping->a_ops = &ntfs_mst_aops;
1015 } else { 1016 } else {
1016 /* It is a file. */ 1017 /* It is a file. */
1017 ntfs_attr_reinit_search_ctx(ctx); 1018 ntfs_attr_reinit_search_ctx(ctx);
@@ -1160,11 +1161,12 @@ no_data_attr_special_case:
1160 /* Setup the operations for this inode. */ 1161 /* Setup the operations for this inode. */
1161 vi->i_op = &ntfs_file_inode_ops; 1162 vi->i_op = &ntfs_file_inode_ops;
1162 vi->i_fop = &ntfs_file_ops; 1163 vi->i_fop = &ntfs_file_ops;
1164 vi->i_mapping->a_ops = &ntfs_normal_aops;
1165 if (NInoMstProtected(ni))
1166 vi->i_mapping->a_ops = &ntfs_mst_aops;
1167 else if (NInoCompressed(ni))
1168 vi->i_mapping->a_ops = &ntfs_compressed_aops;
1163 } 1169 }
1164 if (NInoMstProtected(ni))
1165 vi->i_mapping->a_ops = &ntfs_mst_aops;
1166 else
1167 vi->i_mapping->a_ops = &ntfs_aops;
1168 /* 1170 /*
1169 * The number of 512-byte blocks used on disk (for stat). This is in so 1171 * The number of 512-byte blocks used on disk (for stat). This is in so
1170 * far inaccurate as it doesn't account for any named streams or other 1172 * far inaccurate as it doesn't account for any named streams or other
@@ -1414,10 +1416,11 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
1414 ni->allocated_size = sle64_to_cpu( 1416 ni->allocated_size = sle64_to_cpu(
1415 a->data.non_resident.allocated_size); 1417 a->data.non_resident.allocated_size);
1416 } 1418 }
1419 vi->i_mapping->a_ops = &ntfs_normal_aops;
1417 if (NInoMstProtected(ni)) 1420 if (NInoMstProtected(ni))
1418 vi->i_mapping->a_ops = &ntfs_mst_aops; 1421 vi->i_mapping->a_ops = &ntfs_mst_aops;
1419 else 1422 else if (NInoCompressed(ni))
1420 vi->i_mapping->a_ops = &ntfs_aops; 1423 vi->i_mapping->a_ops = &ntfs_compressed_aops;
1421 if ((NInoCompressed(ni) || NInoSparse(ni)) && ni->type != AT_INDEX_ROOT) 1424 if ((NInoCompressed(ni) || NInoSparse(ni)) && ni->type != AT_INDEX_ROOT)
1422 vi->i_blocks = ni->itype.compressed.size >> 9; 1425 vi->i_blocks = ni->itype.compressed.size >> 9;
1423 else 1426 else
diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h
index d6a340bf80fc..c581e26a350d 100644
--- a/fs/ntfs/ntfs.h
+++ b/fs/ntfs/ntfs.h
@@ -1,8 +1,7 @@
1/* 1/*
2 * ntfs.h - Defines for NTFS Linux kernel driver. Part of the Linux-NTFS 2 * ntfs.h - Defines for NTFS Linux kernel driver.
3 * project.
4 * 3 *
5 * Copyright (c) 2001-2005 Anton Altaparmakov 4 * Copyright (c) 2001-2014 Anton Altaparmakov and Tuxera Inc.
6 * Copyright (C) 2002 Richard Russon 5 * Copyright (C) 2002 Richard Russon
7 * 6 *
8 * This program/include file is free software; you can redistribute it and/or 7 * This program/include file is free software; you can redistribute it and/or
@@ -57,7 +56,8 @@ extern struct kmem_cache *ntfs_attr_ctx_cache;
57extern struct kmem_cache *ntfs_index_ctx_cache; 56extern struct kmem_cache *ntfs_index_ctx_cache;
58 57
59/* The various operations structs defined throughout the driver files. */ 58/* The various operations structs defined throughout the driver files. */
60extern const struct address_space_operations ntfs_aops; 59extern const struct address_space_operations ntfs_normal_aops;
60extern const struct address_space_operations ntfs_compressed_aops;
61extern const struct address_space_operations ntfs_mst_aops; 61extern const struct address_space_operations ntfs_mst_aops;
62 62
63extern const struct file_operations ntfs_file_ops; 63extern const struct file_operations ntfs_file_ops;