Commit 78af34f0 authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: Implement support for sector sizes above 512 bytes (up to the maximum

      supported by NTFS which is 4096 bytes).
parent 7b875aff
...@@ -21,8 +21,14 @@ ToDo/Notes: ...@@ -21,8 +21,14 @@ ToDo/Notes:
2.1.26 - Minor bug fixes and updates. 2.1.26 - Minor bug fixes and updates.
- Fix a potential overflow in file.c where a cast to s64 was missing in
a left shift of a page index.
- The struct inode has had its i_sem semaphore changed to a mutex named
i_mutex.
- We have struct kmem_cache now so use it instead of the typedef - We have struct kmem_cache now so use it instead of the typedef
kmem_cache_t. (Pekka Enberg) kmem_cache_t. (Pekka Enberg)
- Implement support for sector sizes above 512 bytes (up to the maximum
supported by NTFS which is 4096 bytes).
- Miscellaneous updates to layout.h. - Miscellaneous updates to layout.h.
- Cope with attribute list attribute having invalid flags. Windows - Cope with attribute list attribute having invalid flags. Windows
copes with this and even chkdsk does not detect or fix this so we copes with this and even chkdsk does not detect or fix this so we
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aops.c - NTFS kernel address space operations and page cache handling. * aops.c - NTFS kernel address space operations and page cache handling.
* Part of the Linux-NTFS project. * Part of the Linux-NTFS project.
* *
* Copyright (c) 2001-2005 Anton Altaparmakov * Copyright (c) 2001-2006 Anton Altaparmakov
* Copyright (c) 2002 Richard Russon * Copyright (c) 2002 Richard Russon
* *
* This program/include file is free software; you can redistribute it and/or * This program/include file is free software; you can redistribute it and/or
...@@ -200,8 +200,8 @@ static int ntfs_read_block(struct page *page) ...@@ -200,8 +200,8 @@ static int ntfs_read_block(struct page *page)
/* $MFT/$DATA must have its complete runlist in memory at all times. */ /* $MFT/$DATA must have its complete runlist in memory at all times. */
BUG_ON(!ni->runlist.rl && !ni->mft_no && !NInoAttr(ni)); BUG_ON(!ni->runlist.rl && !ni->mft_no && !NInoAttr(ni));
blocksize_bits = VFS_I(ni)->i_blkbits; blocksize = vol->sb->s_blocksize;
blocksize = 1 << blocksize_bits; blocksize_bits = vol->sb->s_blocksize_bits;
if (!page_has_buffers(page)) { if (!page_has_buffers(page)) {
create_empty_buffers(page, blocksize, 0); create_empty_buffers(page, blocksize, 0);
...@@ -569,10 +569,8 @@ static int ntfs_write_block(struct page *page, struct writeback_control *wbc) ...@@ -569,10 +569,8 @@ static int ntfs_write_block(struct page *page, struct writeback_control *wbc)
BUG_ON(!NInoNonResident(ni)); BUG_ON(!NInoNonResident(ni));
BUG_ON(NInoMstProtected(ni)); BUG_ON(NInoMstProtected(ni));
blocksize = vol->sb->s_blocksize;
blocksize_bits = vi->i_blkbits; blocksize_bits = vol->sb->s_blocksize_bits;
blocksize = 1 << blocksize_bits;
if (!page_has_buffers(page)) { if (!page_has_buffers(page)) {
BUG_ON(!PageUptodate(page)); BUG_ON(!PageUptodate(page));
create_empty_buffers(page, blocksize, create_empty_buffers(page, blocksize,
...@@ -949,8 +947,8 @@ static int ntfs_write_mst_block(struct page *page, ...@@ -949,8 +947,8 @@ static int ntfs_write_mst_block(struct page *page,
*/ */
BUG_ON(!(is_mft || S_ISDIR(vi->i_mode) || BUG_ON(!(is_mft || S_ISDIR(vi->i_mode) ||
(NInoAttr(ni) && ni->type == AT_INDEX_ALLOCATION))); (NInoAttr(ni) && ni->type == AT_INDEX_ALLOCATION)));
bh_size_bits = vi->i_blkbits; bh_size = vol->sb->s_blocksize;
bh_size = 1 << bh_size_bits; bh_size_bits = vol->sb->s_blocksize_bits;
max_bhs = PAGE_CACHE_SIZE / bh_size; max_bhs = PAGE_CACHE_SIZE / bh_size;
BUG_ON(!max_bhs); BUG_ON(!max_bhs);
BUG_ON(max_bhs > MAX_BUF_PER_PAGE); BUG_ON(max_bhs > MAX_BUF_PER_PAGE);
...@@ -1596,7 +1594,7 @@ void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) { ...@@ -1596,7 +1594,7 @@ void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs) {
BUG_ON(!PageUptodate(page)); BUG_ON(!PageUptodate(page));
end = ofs + ni->itype.index.block_size; end = ofs + ni->itype.index.block_size;
bh_size = 1 << VFS_I(ni)->i_blkbits; bh_size = VFS_I(ni)->i_sb->s_blocksize;
spin_lock(&mapping->private_lock); spin_lock(&mapping->private_lock);
if (unlikely(!page_has_buffers(page))) { if (unlikely(!page_has_buffers(page))) {
spin_unlock(&mapping->private_lock); spin_unlock(&mapping->private_lock);
......
/* /*
* file.c - NTFS kernel file operations. Part of the Linux-NTFS project. * file.c - NTFS kernel file operations. Part of the Linux-NTFS project.
* *
* Copyright (c) 2001-2005 Anton Altaparmakov * Copyright (c) 2001-2006 Anton Altaparmakov
* *
* This program/include file is free software; you can redistribute it and/or * This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published * modify it under the terms of the GNU General Public License as published
...@@ -529,8 +529,8 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages, ...@@ -529,8 +529,8 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages,
"index 0x%lx, nr_pages 0x%x, pos 0x%llx, bytes 0x%zx.", "index 0x%lx, nr_pages 0x%x, pos 0x%llx, bytes 0x%zx.",
vi->i_ino, ni->type, pages[0]->index, nr_pages, vi->i_ino, ni->type, pages[0]->index, nr_pages,
(long long)pos, bytes); (long long)pos, bytes);
blocksize_bits = vi->i_blkbits; blocksize = vol->sb->s_blocksize;
blocksize = 1 << blocksize_bits; blocksize_bits = vol->sb->s_blocksize_bits;
u = 0; u = 0;
do { do {
struct page *page = pages[u]; struct page *page = pages[u];
...@@ -1525,7 +1525,7 @@ static inline int ntfs_commit_pages_after_non_resident_write( ...@@ -1525,7 +1525,7 @@ static inline int ntfs_commit_pages_after_non_resident_write(
vi = pages[0]->mapping->host; vi = pages[0]->mapping->host;
ni = NTFS_I(vi); ni = NTFS_I(vi);
blocksize = 1 << vi->i_blkbits; blocksize = vi->i_sb->s_blocksize;
end = pos + bytes; end = pos + bytes;
u = 0; u = 0;
do { do {
......
/** /**
* mft.c - NTFS kernel mft record operations. Part of the Linux-NTFS project. * mft.c - NTFS kernel mft record operations. Part of the Linux-NTFS project.
* *
* Copyright (c) 2001-2005 Anton Altaparmakov * Copyright (c) 2001-2006 Anton Altaparmakov
* Copyright (c) 2002 Richard Russon * Copyright (c) 2002 Richard Russon
* *
* This program/include file is free software; you can redistribute it and/or * This program/include file is free software; you can redistribute it and/or
...@@ -473,7 +473,7 @@ int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no, ...@@ -473,7 +473,7 @@ int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no,
runlist_element *rl; runlist_element *rl;
unsigned int block_start, block_end, m_start, m_end, page_ofs; unsigned int block_start, block_end, m_start, m_end, page_ofs;
int i_bhs, nr_bhs, err = 0; int i_bhs, nr_bhs, err = 0;
unsigned char blocksize_bits = vol->mftmirr_ino->i_blkbits; unsigned char blocksize_bits = vol->sb->s_blocksize_bits;
ntfs_debug("Entering for inode 0x%lx.", mft_no); ntfs_debug("Entering for inode 0x%lx.", mft_no);
BUG_ON(!max_bhs); BUG_ON(!max_bhs);
...@@ -672,8 +672,8 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync) ...@@ -672,8 +672,8 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync)
{ {
ntfs_volume *vol = ni->vol; ntfs_volume *vol = ni->vol;
struct page *page = ni->page; struct page *page = ni->page;
unsigned char blocksize_bits = vol->mft_ino->i_blkbits; unsigned int blocksize = vol->sb->s_blocksize;
unsigned int blocksize = 1 << blocksize_bits; unsigned char blocksize_bits = vol->sb->s_blocksize_bits;
int max_bhs = vol->mft_record_size / blocksize; int max_bhs = vol->mft_record_size / blocksize;
struct buffer_head *bhs[max_bhs]; struct buffer_head *bhs[max_bhs];
struct buffer_head *bh, *head; struct buffer_head *bh, *head;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment