Commit 4678d45d authored by Anton Altaparmakov's avatar Anton Altaparmakov

Merge ssh://linux-ntfs@bkbits.net/ntfs-2.6-devel

into cantab.net:/home/src/ntfs-2.6-devel
parents 0ed0b64d ddd2ef70
......@@ -25,6 +25,11 @@ ToDo/Notes:
- Implement extent mft record deallocation
fs/ntfs/mft.c::ntfs_extent_mft_record_free().
- Splitt runlist related functions off from attrib.[hc] to runlist.[hc].
- Add vol->mft_data_pos and initialize it at mount time.
- Rename init_runlist() to ntfs_init_runlist(), ntfs_vcn_to_lcn() to
ntfs_rl_vcn_to_lcn(), decompress_mapping_pairs() to
ntfs_mapping_pairs_decompress() and adapt all callers.
2.1.19 - Many cleanups, improvements, and a minor bug fix.
......
......@@ -3,8 +3,8 @@
obj-$(CONFIG_NTFS_FS) += ntfs.o
ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \
index.o inode.o mft.o mst.o namei.o super.o sysctl.o unistr.o \
upcase.o
index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \
unistr.o upcase.o
EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.20-WIP\"
......
......@@ -232,7 +232,7 @@ static int ntfs_read_block(struct page *page)
/* Seek to element containing target vcn. */
while (rl->length && rl[1].vcn <= vcn)
rl++;
lcn = ntfs_vcn_to_lcn(rl, vcn);
lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
} else
lcn = (LCN)LCN_RL_NOT_MAPPED;
/* Successful remap. */
......@@ -266,7 +266,7 @@ static int ntfs_read_block(struct page *page)
}
/* Hard error, zero out region. */
SetPageError(page);
ntfs_error(vol->sb, "ntfs_vcn_to_lcn(vcn = 0x%llx) "
ntfs_error(vol->sb, "ntfs_rl_vcn_to_lcn(vcn = 0x%llx) "
"failed with error code 0x%llx%s.",
(unsigned long long)vcn,
(unsigned long long)-lcn,
......@@ -274,9 +274,9 @@ static int ntfs_read_block(struct page *page)
// FIXME: Depending on vol->on_errors, do something.
}
/*
* Either iblock was outside lblock limits or ntfs_vcn_to_lcn()
* returned error. Just zero that portion of the page and set
* the buffer uptodate.
* Either iblock was outside lblock limits or
* ntfs_rl_vcn_to_lcn() returned error. Just zero that portion
* of the page and set the buffer uptodate.
*/
handle_hole:
bh->b_blocknr = -1UL;
......@@ -637,7 +637,7 @@ static int ntfs_write_block(struct writeback_control *wbc, struct page *page)
/* Seek to element containing target vcn. */
while (rl->length && rl[1].vcn <= vcn)
rl++;
lcn = ntfs_vcn_to_lcn(rl, vcn);
lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
} else
lcn = (LCN)LCN_RL_NOT_MAPPED;
/* Successful remap. */
......@@ -673,7 +673,7 @@ static int ntfs_write_block(struct writeback_control *wbc, struct page *page)
}
/* Failed to map the buffer, even after retrying. */
bh->b_blocknr = -1UL;
ntfs_error(vol->sb, "ntfs_vcn_to_lcn(vcn = 0x%llx) failed "
ntfs_error(vol->sb, "ntfs_rl_vcn_to_lcn(vcn = 0x%llx) failed "
"with error code 0x%llx%s.",
(unsigned long long)vcn,
(unsigned long long)-lcn,
......@@ -1402,7 +1402,7 @@ static int ntfs_prepare_nonresident_write(struct page *page,
/* Seek to element containing target vcn. */
while (rl->length && rl[1].vcn <= vcn)
rl++;
lcn = ntfs_vcn_to_lcn(rl, vcn);
lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
} else
lcn = (LCN)LCN_RL_NOT_MAPPED;
if (unlikely(lcn < 0)) {
......@@ -1451,7 +1451,7 @@ static int ntfs_prepare_nonresident_write(struct page *page,
* retrying.
*/
bh->b_blocknr = -1UL;
ntfs_error(vol->sb, "ntfs_vcn_to_lcn(vcn = "
ntfs_error(vol->sb, "ntfs_rl_vcn_to_lcn(vcn = "
"0x%llx) failed with error "
"code 0x%llx%s.",
(unsigned long long)vcn,
......
This diff is collapsed.
......@@ -24,23 +24,11 @@
#ifndef _LINUX_NTFS_ATTRIB_H
#define _LINUX_NTFS_ATTRIB_H
#include <linux/fs.h>
#include "endian.h"
#include "types.h"
#include "layout.h"
static inline void init_runlist(runlist *rl)
{
rl->rl = NULL;
init_rwsem(&rl->lock);
}
typedef enum {
LCN_HOLE = -1, /* Keep this as highest value or die! */
LCN_RL_NOT_MAPPED = -2,
LCN_ENOENT = -3,
} LCN_SPECIAL_VALUES;
#include "inode.h"
#include "runlist.h"
/**
* ntfs_attr_search_ctx - used in attribute search functions
......@@ -71,13 +59,8 @@ typedef struct {
ATTR_RECORD *base_attr;
} ntfs_attr_search_ctx;
extern runlist_element *decompress_mapping_pairs(const ntfs_volume *vol,
const ATTR_RECORD *attr, runlist_element *old_rl);
extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn);
extern LCN ntfs_vcn_to_lcn(const runlist_element *rl, const VCN vcn);
extern runlist_element *ntfs_find_vcn(ntfs_inode *ni, const VCN vcn,
const BOOL need_write);
......
......@@ -600,7 +600,7 @@ int ntfs_read_compressed_block(struct page *page)
/* Seek to element containing target vcn. */
while (rl->length && rl[1].vcn <= vcn)
rl++;
lcn = ntfs_vcn_to_lcn(rl, vcn);
lcn = ntfs_rl_vcn_to_lcn(rl, vcn);
} else
lcn = (LCN)LCN_RL_NOT_MAPPED;
ntfs_debug("Reading vcn = 0x%llx, lcn = 0x%llx.",
......@@ -926,7 +926,7 @@ int ntfs_read_compressed_block(struct page *page)
rl_err:
up_read(&ni->runlist.lock);
ntfs_error(vol->sb, "ntfs_vcn_to_lcn() failed. Cannot read "
ntfs_error(vol->sb, "ntfs_rl_vcn_to_lcn() failed. Cannot read "
"compression block.");
goto err_out;
......
......@@ -376,13 +376,13 @@ static void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni)
ni->seq_no = 0;
atomic_set(&ni->count, 1);
ni->vol = NTFS_SB(sb);
init_runlist(&ni->runlist);
ntfs_init_runlist(&ni->runlist);
init_MUTEX(&ni->mrec_lock);
ni->page = NULL;
ni->page_ofs = 0;
ni->attr_list_size = 0;
ni->attr_list = NULL;
init_runlist(&ni->attr_list_rl);
ntfs_init_runlist(&ni->attr_list_rl);
ni->itype.index.bmp_ino = NULL;
ni->itype.index.block_size = 0;
ni->itype.index.vcn_size = 0;
......@@ -701,7 +701,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
* Setup the runlist. No need for locking as we have
* exclusive access to the inode at this time.
*/
ni->attr_list_rl.rl = decompress_mapping_pairs(vol,
ni->attr_list_rl.rl = ntfs_mapping_pairs_decompress(vol,
ctx->attr, NULL);
if (IS_ERR(ni->attr_list_rl.rl)) {
err = PTR_ERR(ni->attr_list_rl.rl);
......@@ -1672,7 +1672,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
*
* We solve these problems by starting with the $DATA attribute before anything
* else and iterating using ntfs_attr_lookup($DATA) over all extents. As each
* extent is found, we decompress_mapping_pairs() including the implied
* extent is found, we ntfs_mapping_pairs_decompress() including the implied
* ntfs_merge_runlists(). Each step of the iteration necessarily provides
* sufficient information for the next step to complete.
*
......@@ -1810,7 +1810,7 @@ int ntfs_read_inode_mount(struct inode *vi)
goto put_err_out;
}
/* Setup the runlist. */
ni->attr_list_rl.rl = decompress_mapping_pairs(vol,
ni->attr_list_rl.rl = ntfs_mapping_pairs_decompress(vol,
ctx->attr, NULL);
if (IS_ERR(ni->attr_list_rl.rl)) {
err = PTR_ERR(ni->attr_list_rl.rl);
......@@ -1942,11 +1942,11 @@ int ntfs_read_inode_mount(struct inode *vi)
* as we have exclusive access to the inode at this time and we
* are a mount in progress task, too.
*/
nrl = decompress_mapping_pairs(vol, attr, ni->runlist.rl);
nrl = ntfs_mapping_pairs_decompress(vol, attr, ni->runlist.rl);
if (IS_ERR(nrl)) {
ntfs_error(sb, "decompress_mapping_pairs() failed with "
"error code %ld. $MFT is corrupt.",
PTR_ERR(nrl));
ntfs_error(sb, "ntfs_mapping_pairs_decompress() "
"failed with error code %ld. $MFT is "
"corrupt.", PTR_ERR(nrl));
goto put_err_out;
}
ni->runlist.rl = nrl;
......
This diff is collapsed.
/*
* runlist.h - Defines for runlist handling in NTFS Linux kernel driver.
* Part of the Linux-NTFS project.
*
* Copyright (c) 2001-2004 Anton Altaparmakov
* Copyright (c) 2002 Richard Russon
*
* 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
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program/include file is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of 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 (in the main directory of the Linux-NTFS
* distribution in the file COPYING); if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LINUX_NTFS_RUNLIST_H
#define _LINUX_NTFS_RUNLIST_H
#include "types.h"
#include "layout.h"
#include "volume.h"
static inline void ntfs_init_runlist(runlist *rl)
{
rl->rl = NULL;
init_rwsem(&rl->lock);
}
typedef enum {
LCN_HOLE = -1, /* Keep this as highest value or die! */
LCN_RL_NOT_MAPPED = -2,
LCN_ENOENT = -3,
} LCN_SPECIAL_VALUES;
extern runlist_element *ntfs_mapping_pairs_decompress(const ntfs_volume *vol,
const ATTR_RECORD *attr, runlist_element *old_rl);
extern LCN ntfs_rl_vcn_to_lcn(const runlist_element *rl, const VCN vcn);
#endif /* _LINUX_NTFS_RUNLIST_H */
......@@ -827,12 +827,12 @@ static BOOL parse_ntfs_boot_sector(ntfs_volume *vol, const NTFS_BOOT_SECTOR *b)
}
/**
* setup_lcn_allocator - initialize the cluster allocator
* @vol: volume structure for which to setup the lcn allocator
* ntfs_setup_allocators - initialize the cluster and mft allocators
* @vol: volume structure for which to setup the allocators
*
* Setup the cluster (lcn) allocator to the starting values.
* Setup the cluster (lcn) and mft allocators to the starting values.
*/
static void setup_lcn_allocator(ntfs_volume *vol)
static void ntfs_setup_allocators(ntfs_volume *vol)
{
#ifdef NTFS_RW
LCN mft_zone_size, mft_lcn;
......@@ -902,6 +902,11 @@ static void setup_lcn_allocator(ntfs_volume *vol)
vol->data2_zone_pos = 0;
ntfs_debug("vol->data2_zone_pos = 0x%llx",
(unsigned long long)vol->data2_zone_pos);
/* Set the mft data allocation position to mft record 24. */
vol->mft_data_pos = 24;
ntfs_debug("vol->mft_data_pos = 0x%llx",
(unsigned long long)vol->mft_data_pos);
#endif /* NTFS_RW */
}
......@@ -2334,8 +2339,8 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
*/
result = parse_ntfs_boot_sector(vol, (NTFS_BOOT_SECTOR*)bh->b_data);
/* Initialize the cluster allocator. */
setup_lcn_allocator(vol);
/* Initialize the cluster and mft allocators. */
ntfs_setup_allocators(vol);
brelse(bh);
......
......@@ -81,6 +81,8 @@ typedef struct {
#ifdef NTFS_RW
/* Variables used by the cluster and mft allocators. */
s64 mft_data_pos; /* Mft record number at which to
allocate the next mft record. */
LCN mft_zone_start; /* First cluster of the mft zone. */
LCN mft_zone_end; /* First cluster beyond the mft zone. */
LCN mft_zone_pos; /* Current position in the mft zone. */
......
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