aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfs/inode.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /fs/hfs/inode.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'fs/hfs/inode.c')
-rw-r--r--fs/hfs/inode.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index d47f11658c1..96a1b625fc7 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -35,16 +35,6 @@ static int hfs_readpage(struct file *file, struct page *page)
35 return block_read_full_page(page, hfs_get_block); 35 return block_read_full_page(page, hfs_get_block);
36} 36}
37 37
38static void hfs_write_failed(struct address_space *mapping, loff_t to)
39{
40 struct inode *inode = mapping->host;
41
42 if (to > inode->i_size) {
43 truncate_pagecache(inode, to, inode->i_size);
44 hfs_file_truncate(inode);
45 }
46}
47
48static int hfs_write_begin(struct file *file, struct address_space *mapping, 38static int hfs_write_begin(struct file *file, struct address_space *mapping,
49 loff_t pos, unsigned len, unsigned flags, 39 loff_t pos, unsigned len, unsigned flags,
50 struct page **pagep, void **fsdata) 40 struct page **pagep, void **fsdata)
@@ -55,8 +45,11 @@ static int hfs_write_begin(struct file *file, struct address_space *mapping,
55 ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata, 45 ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
56 hfs_get_block, 46 hfs_get_block,
57 &HFS_I(mapping->host)->phys_size); 47 &HFS_I(mapping->host)->phys_size);
58 if (unlikely(ret)) 48 if (unlikely(ret)) {
59 hfs_write_failed(mapping, pos + len); 49 loff_t isize = mapping->host->i_size;
50 if (pos + len > isize)
51 vmtruncate(mapping->host, isize);
52 }
60 53
61 return ret; 54 return ret;
62} 55}
@@ -127,7 +120,6 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
127 const struct iovec *iov, loff_t offset, unsigned long nr_segs) 120 const struct iovec *iov, loff_t offset, unsigned long nr_segs)
128{ 121{
129 struct file *file = iocb->ki_filp; 122 struct file *file = iocb->ki_filp;
130 struct address_space *mapping = file->f_mapping;
131 struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; 123 struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
132 ssize_t ret; 124 ssize_t ret;
133 125
@@ -143,7 +135,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
143 loff_t end = offset + iov_length(iov, nr_segs); 135 loff_t end = offset + iov_length(iov, nr_segs);
144 136
145 if (end > isize) 137 if (end > isize)
146 hfs_write_failed(mapping, end); 138 vmtruncate(inode, isize);
147 } 139 }
148 140
149 return ret; 141 return ret;
@@ -177,7 +169,7 @@ const struct address_space_operations hfs_aops = {
177/* 169/*
178 * hfs_new_inode 170 * hfs_new_inode
179 */ 171 */
180struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, umode_t mode) 172struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, int mode)
181{ 173{
182 struct super_block *sb = dir->i_sb; 174 struct super_block *sb = dir->i_sb;
183 struct inode *inode = new_inode(sb); 175 struct inode *inode = new_inode(sb);
@@ -191,7 +183,7 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, umode_t mode)
191 inode->i_mode = mode; 183 inode->i_mode = mode;
192 inode->i_uid = current_fsuid(); 184 inode->i_uid = current_fsuid();
193 inode->i_gid = current_fsgid(); 185 inode->i_gid = current_fsgid();
194 set_nlink(inode, 1); 186 inode->i_nlink = 1;
195 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 187 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
196 HFS_I(inode)->flags = 0; 188 HFS_I(inode)->flags = 0;
197 HFS_I(inode)->rsrc_inode = NULL; 189 HFS_I(inode)->rsrc_inode = NULL;
@@ -228,7 +220,7 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, umode_t mode)
228 insert_inode_hash(inode); 220 insert_inode_hash(inode);
229 mark_inode_dirty(inode); 221 mark_inode_dirty(inode);
230 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags); 222 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
231 hfs_mark_mdb_dirty(sb); 223 sb->s_dirt = 1;
232 224
233 return inode; 225 return inode;
234} 226}
@@ -243,7 +235,7 @@ void hfs_delete_inode(struct inode *inode)
243 if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID)) 235 if (HFS_I(inode)->cat_key.ParID == cpu_to_be32(HFS_ROOT_CNID))
244 HFS_SB(sb)->root_dirs--; 236 HFS_SB(sb)->root_dirs--;
245 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags); 237 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
246 hfs_mark_mdb_dirty(sb); 238 sb->s_dirt = 1;
247 return; 239 return;
248 } 240 }
249 HFS_SB(sb)->file_count--; 241 HFS_SB(sb)->file_count--;
@@ -256,7 +248,7 @@ void hfs_delete_inode(struct inode *inode)
256 } 248 }
257 } 249 }
258 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags); 250 set_bit(HFS_FLG_MDB_DIRTY, &HFS_SB(sb)->flags);
259 hfs_mark_mdb_dirty(sb); 251 sb->s_dirt = 1;
260} 252}
261 253
262void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext, 254void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
@@ -321,7 +313,7 @@ static int hfs_read_inode(struct inode *inode, void *data)
321 /* Initialize the inode */ 313 /* Initialize the inode */
322 inode->i_uid = hsb->s_uid; 314 inode->i_uid = hsb->s_uid;
323 inode->i_gid = hsb->s_gid; 315 inode->i_gid = hsb->s_gid;
324 set_nlink(inode, 1); 316 inode->i_nlink = 1;
325 317
326 if (idata->key) 318 if (idata->key)
327 HFS_I(inode)->cat_key = *idata->key; 319 HFS_I(inode)->cat_key = *idata->key;
@@ -497,7 +489,7 @@ out:
497} 489}
498 490
499static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry, 491static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry,
500 unsigned int flags) 492 struct nameidata *nd)
501{ 493{
502 struct inode *inode = NULL; 494 struct inode *inode = NULL;
503 hfs_cat_rec rec; 495 hfs_cat_rec rec;
@@ -540,7 +532,7 @@ out:
540void hfs_evict_inode(struct inode *inode) 532void hfs_evict_inode(struct inode *inode)
541{ 533{
542 truncate_inode_pages(&inode->i_data, 0); 534 truncate_inode_pages(&inode->i_data, 0);
543 clear_inode(inode); 535 end_writeback(inode);
544 if (HFS_IS_RSRC(inode) && HFS_I(inode)->rsrc_inode) { 536 if (HFS_IS_RSRC(inode) && HFS_I(inode)->rsrc_inode) {
545 HFS_I(HFS_I(inode)->rsrc_inode)->rsrc_inode = NULL; 537 HFS_I(HFS_I(inode)->rsrc_inode)->rsrc_inode = NULL;
546 iput(HFS_I(inode)->rsrc_inode); 538 iput(HFS_I(inode)->rsrc_inode);
@@ -602,9 +594,9 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
602 594
603 /* no uig/gid changes and limit which mode bits can be set */ 595 /* no uig/gid changes and limit which mode bits can be set */
604 if (((attr->ia_valid & ATTR_UID) && 596 if (((attr->ia_valid & ATTR_UID) &&
605 (!uid_eq(attr->ia_uid, hsb->s_uid))) || 597 (attr->ia_uid != hsb->s_uid)) ||
606 ((attr->ia_valid & ATTR_GID) && 598 ((attr->ia_valid & ATTR_GID) &&
607 (!gid_eq(attr->ia_gid, hsb->s_gid))) || 599 (attr->ia_gid != hsb->s_gid)) ||
608 ((attr->ia_valid & ATTR_MODE) && 600 ((attr->ia_valid & ATTR_MODE) &&
609 ((S_ISDIR(inode->i_mode) && 601 ((S_ISDIR(inode->i_mode) &&
610 (attr->ia_mode != inode->i_mode)) || 602 (attr->ia_mode != inode->i_mode)) ||
@@ -625,12 +617,9 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
625 attr->ia_size != i_size_read(inode)) { 617 attr->ia_size != i_size_read(inode)) {
626 inode_dio_wait(inode); 618 inode_dio_wait(inode);
627 619
628 error = inode_newsize_ok(inode, attr->ia_size); 620 error = vmtruncate(inode, attr->ia_size);
629 if (error) 621 if (error)
630 return error; 622 return error;
631
632 truncate_setsize(inode, attr->ia_size);
633 hfs_file_truncate(inode);
634 } 623 }
635 624
636 setattr_copy(inode, attr); 625 setattr_copy(inode, attr);
@@ -655,7 +644,13 @@ static int hfs_file_fsync(struct file *filp, loff_t start, loff_t end,
655 644
656 /* sync the superblock to buffers */ 645 /* sync the superblock to buffers */
657 sb = inode->i_sb; 646 sb = inode->i_sb;
658 flush_delayed_work(&HFS_SB(sb)->mdb_work); 647 if (sb->s_dirt) {
648 lock_super(sb);
649 sb->s_dirt = 0;
650 if (!(sb->s_flags & MS_RDONLY))
651 hfs_mdb_commit(sb);
652 unlock_super(sb);
653 }
659 /* .. finally sync the buffers to disk */ 654 /* .. finally sync the buffers to disk */
660 err = sync_blockdev(sb->s_bdev); 655 err = sync_blockdev(sb->s_bdev);
661 if (!ret) 656 if (!ret)
@@ -679,6 +674,7 @@ static const struct file_operations hfs_file_operations = {
679 674
680static const struct inode_operations hfs_file_inode_operations = { 675static const struct inode_operations hfs_file_inode_operations = {
681 .lookup = hfs_file_lookup, 676 .lookup = hfs_file_lookup,
677 .truncate = hfs_file_truncate,
682 .setattr = hfs_inode_setattr, 678 .setattr = hfs_inode_setattr,
683 .setxattr = hfs_setxattr, 679 .setxattr = hfs_setxattr,
684 .getxattr = hfs_getxattr, 680 .getxattr = hfs_getxattr,