Commit f684073c authored by Konstantin Komarov's avatar Konstantin Komarov

fs/ntfs3: Refactoring and comments

Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
parent dcc852e5
...@@ -1106,10 +1106,10 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn, ...@@ -1106,10 +1106,10 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
} }
} }
/* /*
* The code below may require additional cluster (to extend attribute list) * The code below may require additional cluster (to extend attribute list)
* and / or one MFT record * and / or one MFT record
* It is too complex to undo operations if -ENOSPC occurs deep inside * It is too complex to undo operations if -ENOSPC occurs deep inside
* in 'ni_insert_nonresident'. * in 'ni_insert_nonresident'.
* Return in advance -ENOSPC here if there are no free cluster and no free MFT. * Return in advance -ENOSPC here if there are no free cluster and no free MFT.
*/ */
......
...@@ -745,8 +745,8 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) ...@@ -745,8 +745,8 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
} }
static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos, static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe, struct pipe_inode_info *pipe, size_t len,
size_t len, unsigned int flags) unsigned int flags)
{ {
struct inode *inode = in->f_mapping->host; struct inode *inode = in->f_mapping->host;
struct ntfs_inode *ni = ntfs_i(inode); struct ntfs_inode *ni = ntfs_i(inode);
......
...@@ -1660,7 +1660,8 @@ struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, ...@@ -1660,7 +1660,8 @@ struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
/* Set original time. inode times (i_ctime) may be changed in ntfs_init_acl. */ /* Set original time. inode times (i_ctime) may be changed in ntfs_init_acl. */
inode->i_atime = inode->i_mtime = inode_set_ctime_to_ts(inode, ni->i_crtime); inode->i_atime = inode->i_mtime =
inode_set_ctime_to_ts(inode, ni->i_crtime);
dir->i_mtime = inode_set_ctime_to_ts(dir, ni->i_crtime); dir->i_mtime = inode_set_ctime_to_ts(dir, ni->i_crtime);
mark_inode_dirty(dir); mark_inode_dirty(dir);
......
...@@ -156,8 +156,8 @@ static int ntfs_link(struct dentry *ode, struct inode *dir, struct dentry *de) ...@@ -156,8 +156,8 @@ static int ntfs_link(struct dentry *ode, struct inode *dir, struct dentry *de)
err = ntfs_link_inode(inode, de); err = ntfs_link_inode(inode, de);
if (!err) { if (!err) {
dir->i_mtime = inode_set_ctime_to_ts(inode, dir->i_mtime = inode_set_ctime_to_ts(
inode_set_ctime_current(dir)); inode, inode_set_ctime_current(dir));
mark_inode_dirty(inode); mark_inode_dirty(inode);
mark_inode_dirty(dir); mark_inode_dirty(dir);
d_instantiate(de, inode); d_instantiate(de, inode);
...@@ -373,7 +373,7 @@ static int ntfs_atomic_open(struct inode *dir, struct dentry *dentry, ...@@ -373,7 +373,7 @@ static int ntfs_atomic_open(struct inode *dir, struct dentry *dentry,
#ifdef CONFIG_NTFS3_FS_POSIX_ACL #ifdef CONFIG_NTFS3_FS_POSIX_ACL
if (IS_POSIXACL(dir)) { if (IS_POSIXACL(dir)) {
/* /*
* Load in cache current acl to avoid ni_lock(dir): * Load in cache current acl to avoid ni_lock(dir):
* ntfs_create_inode -> ntfs_init_acl -> posix_acl_create -> * ntfs_create_inode -> ntfs_init_acl -> posix_acl_create ->
* ntfs_get_acl -> ntfs_get_acl_ex -> ni_lock * ntfs_get_acl -> ntfs_get_acl_ex -> ni_lock
......
...@@ -847,7 +847,7 @@ struct OBJECT_ID { ...@@ -847,7 +847,7 @@ struct OBJECT_ID {
// Birth Volume Id is the Object Id of the Volume on. // Birth Volume Id is the Object Id of the Volume on.
// which the Object Id was allocated. It never changes. // which the Object Id was allocated. It never changes.
struct GUID BirthVolumeId; //0x10: struct GUID BirthVolumeId; //0x10:
// Birth Object Id is the first Object Id that was // Birth Object Id is the first Object Id that was
// ever assigned to this MFT Record. I.e. If the Object Id // ever assigned to this MFT Record. I.e. If the Object Id
// is changed for some reason, this field will reflect the // is changed for some reason, this field will reflect the
......
...@@ -497,8 +497,6 @@ int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path, ...@@ -497,8 +497,6 @@ int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, u32 flags); struct kstat *stat, u32 request_mask, u32 flags);
int ntfs3_setattr(struct mnt_idmap *idmap, struct dentry *dentry, int ntfs3_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr); struct iattr *attr);
void ntfs_sparse_cluster(struct inode *inode, struct page *page0, CLST vcn,
CLST len);
int ntfs_file_open(struct inode *inode, struct file *file); int ntfs_file_open(struct inode *inode, struct file *file);
int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
__u64 start, __u64 len); __u64 start, __u64 len);
......
...@@ -189,6 +189,12 @@ int mi_read(struct mft_inode *mi, bool is_mft) ...@@ -189,6 +189,12 @@ int mi_read(struct mft_inode *mi, bool is_mft)
return err; return err;
} }
/*
* mi_enum_attr - start/continue attributes enumeration in record.
*
* NOTE: mi->mrec - memory of size sbi->record_size
* here we sure that mi->mrec->total == sbi->record_size (see mi_read)
*/
struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr) struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr)
{ {
const struct MFT_REC *rec = mi->mrec; const struct MFT_REC *rec = mi->mrec;
......
...@@ -488,7 +488,6 @@ static ssize_t ntfs3_label_write(struct file *file, const char __user *buffer, ...@@ -488,7 +488,6 @@ static ssize_t ntfs3_label_write(struct file *file, const char __user *buffer,
{ {
int err; int err;
struct super_block *sb = pde_data(file_inode(file)); struct super_block *sb = pde_data(file_inode(file));
struct ntfs_sb_info *sbi = sb->s_fs_info;
ssize_t ret = count; ssize_t ret = count;
u8 *label = kmalloc(count, GFP_NOFS); u8 *label = kmalloc(count, GFP_NOFS);
...@@ -502,7 +501,7 @@ static ssize_t ntfs3_label_write(struct file *file, const char __user *buffer, ...@@ -502,7 +501,7 @@ static ssize_t ntfs3_label_write(struct file *file, const char __user *buffer,
while (ret > 0 && label[ret - 1] == '\n') while (ret > 0 && label[ret - 1] == '\n')
ret -= 1; ret -= 1;
err = ntfs_set_label(sbi, label, ret); err = ntfs_set_label(sb->s_fs_info, label, ret);
if (err < 0) { if (err < 0) {
ntfs_err(sb, "failed (%d) to write label", err); ntfs_err(sb, "failed (%d) to write label", err);
...@@ -1082,10 +1081,10 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size, ...@@ -1082,10 +1081,10 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
if (bh->b_blocknr && !sb_rdonly(sb)) { if (bh->b_blocknr && !sb_rdonly(sb)) {
/* /*
* Alternative boot is ok but primary is not ok. * Alternative boot is ok but primary is not ok.
* Do not update primary boot here 'cause it may be faked boot. * Do not update primary boot here 'cause it may be faked boot.
* Let ntfs to be mounted and update boot later. * Let ntfs to be mounted and update boot later.
*/ */
*boot2 = kmemdup(boot, sizeof(*boot), GFP_NOFS | __GFP_NOWARN); *boot2 = kmemdup(boot, sizeof(*boot), GFP_NOFS | __GFP_NOWARN);
} }
...@@ -1549,9 +1548,9 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1549,9 +1548,9 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
if (boot2) { if (boot2) {
/* /*
* Alternative boot is ok but primary is not ok. * Alternative boot is ok but primary is not ok.
* Volume is recognized as NTFS. Update primary boot. * Volume is recognized as NTFS. Update primary boot.
*/ */
struct buffer_head *bh0 = sb_getblk(sb, 0); struct buffer_head *bh0 = sb_getblk(sb, 0);
if (bh0) { if (bh0) {
if (buffer_locked(bh0)) if (buffer_locked(bh0))
...@@ -1785,7 +1784,6 @@ static int __init init_ntfs_fs(void) ...@@ -1785,7 +1784,6 @@ static int __init init_ntfs_fs(void)
if (IS_ENABLED(CONFIG_NTFS3_LZX_XPRESS)) if (IS_ENABLED(CONFIG_NTFS3_LZX_XPRESS))
pr_info("ntfs3: Read-only LZX/Xpress compression included\n"); pr_info("ntfs3: Read-only LZX/Xpress compression included\n");
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
/* Create "/proc/fs/ntfs3" */ /* Create "/proc/fs/ntfs3" */
proc_info_root = proc_mkdir("fs/ntfs3", NULL); proc_info_root = proc_mkdir("fs/ntfs3", NULL);
...@@ -1827,7 +1825,6 @@ static void __exit exit_ntfs_fs(void) ...@@ -1827,7 +1825,6 @@ static void __exit exit_ntfs_fs(void)
if (proc_info_root) if (proc_info_root)
remove_proc_entry("fs/ntfs3", NULL); remove_proc_entry("fs/ntfs3", NULL);
#endif #endif
} }
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
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