aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/inode.c
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2012-10-09 10:03:21 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-10-09 10:04:25 -0400
commitffe315012510165ce82e4dd4767f0a5dba9edbf7 (patch)
treef601cd980af9d0ced5ca9aedecef4fa0d2ca0e15 /fs/udf/inode.c
parente2d3a35ee427aaba99b6c68a56609ce276c51270 (diff)
parent4a8e43feeac7996b8de2d5b2823e316917493df4 (diff)
Merge tag 'disintegrate-mtd-20121009' of git://git.infradead.org/users/dhowells/linux-headers
UAPI Disintegration 2012-10-09 Conflicts: MAINTAINERS arch/arm/configs/bcmring_defconfig arch/arm/mach-imx/clk-imx51-imx53.c drivers/mtd/nand/Kconfig drivers/mtd/nand/bcm_umi_nand.c drivers/mtd/nand/nand_bcm_umi.h drivers/mtd/nand/orion_nand.c
Diffstat (limited to 'fs/udf/inode.c')
-rw-r--r--fs/udf/inode.c76
1 files changed, 53 insertions, 23 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index fafaad795cd6..df88b957ccf0 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -95,11 +95,33 @@ void udf_evict_inode(struct inode *inode)
95 } 95 }
96} 96}
97 97
98static void udf_write_failed(struct address_space *mapping, loff_t to)
99{
100 struct inode *inode = mapping->host;
101 struct udf_inode_info *iinfo = UDF_I(inode);
102 loff_t isize = inode->i_size;
103
104 if (to > isize) {
105 truncate_pagecache(inode, to, isize);
106 if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
107 down_write(&iinfo->i_data_sem);
108 udf_truncate_extents(inode);
109 up_write(&iinfo->i_data_sem);
110 }
111 }
112}
113
98static int udf_writepage(struct page *page, struct writeback_control *wbc) 114static int udf_writepage(struct page *page, struct writeback_control *wbc)
99{ 115{
100 return block_write_full_page(page, udf_get_block, wbc); 116 return block_write_full_page(page, udf_get_block, wbc);
101} 117}
102 118
119static int udf_writepages(struct address_space *mapping,
120 struct writeback_control *wbc)
121{
122 return mpage_writepages(mapping, wbc, udf_get_block);
123}
124
103static int udf_readpage(struct file *file, struct page *page) 125static int udf_readpage(struct file *file, struct page *page)
104{ 126{
105 return mpage_readpage(page, udf_get_block); 127 return mpage_readpage(page, udf_get_block);
@@ -118,21 +140,24 @@ static int udf_write_begin(struct file *file, struct address_space *mapping,
118 int ret; 140 int ret;
119 141
120 ret = block_write_begin(mapping, pos, len, flags, pagep, udf_get_block); 142 ret = block_write_begin(mapping, pos, len, flags, pagep, udf_get_block);
121 if (unlikely(ret)) { 143 if (unlikely(ret))
122 struct inode *inode = mapping->host; 144 udf_write_failed(mapping, pos + len);
123 struct udf_inode_info *iinfo = UDF_I(inode); 145 return ret;
124 loff_t isize = inode->i_size; 146}
125
126 if (pos + len > isize) {
127 truncate_pagecache(inode, pos + len, isize);
128 if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
129 down_write(&iinfo->i_data_sem);
130 udf_truncate_extents(inode);
131 up_write(&iinfo->i_data_sem);
132 }
133 }
134 }
135 147
148static ssize_t udf_direct_IO(int rw, struct kiocb *iocb,
149 const struct iovec *iov,
150 loff_t offset, unsigned long nr_segs)
151{
152 struct file *file = iocb->ki_filp;
153 struct address_space *mapping = file->f_mapping;
154 struct inode *inode = mapping->host;
155 ssize_t ret;
156
157 ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
158 udf_get_block);
159 if (unlikely(ret < 0 && (rw & WRITE)))
160 udf_write_failed(mapping, offset + iov_length(iov, nr_segs));
136 return ret; 161 return ret;
137} 162}
138 163
@@ -145,8 +170,10 @@ const struct address_space_operations udf_aops = {
145 .readpage = udf_readpage, 170 .readpage = udf_readpage,
146 .readpages = udf_readpages, 171 .readpages = udf_readpages,
147 .writepage = udf_writepage, 172 .writepage = udf_writepage,
148 .write_begin = udf_write_begin, 173 .writepages = udf_writepages,
149 .write_end = generic_write_end, 174 .write_begin = udf_write_begin,
175 .write_end = generic_write_end,
176 .direct_IO = udf_direct_IO,
150 .bmap = udf_bmap, 177 .bmap = udf_bmap,
151}; 178};
152 179
@@ -1124,14 +1151,17 @@ int udf_setsize(struct inode *inode, loff_t newsize)
1124 if (err) 1151 if (err)
1125 return err; 1152 return err;
1126 down_write(&iinfo->i_data_sem); 1153 down_write(&iinfo->i_data_sem);
1127 } else 1154 } else {
1128 iinfo->i_lenAlloc = newsize; 1155 iinfo->i_lenAlloc = newsize;
1156 goto set_size;
1157 }
1129 } 1158 }
1130 err = udf_extend_file(inode, newsize); 1159 err = udf_extend_file(inode, newsize);
1131 if (err) { 1160 if (err) {
1132 up_write(&iinfo->i_data_sem); 1161 up_write(&iinfo->i_data_sem);
1133 return err; 1162 return err;
1134 } 1163 }
1164set_size:
1135 truncate_setsize(inode, newsize); 1165 truncate_setsize(inode, newsize);
1136 up_write(&iinfo->i_data_sem); 1166 up_write(&iinfo->i_data_sem);
1137 } else { 1167 } else {
@@ -1309,14 +1339,14 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1309 } 1339 }
1310 1340
1311 read_lock(&sbi->s_cred_lock); 1341 read_lock(&sbi->s_cred_lock);
1312 inode->i_uid = le32_to_cpu(fe->uid); 1342 i_uid_write(inode, le32_to_cpu(fe->uid));
1313 if (inode->i_uid == -1 || 1343 if (!uid_valid(inode->i_uid) ||
1314 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) || 1344 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) ||
1315 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET)) 1345 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET))
1316 inode->i_uid = UDF_SB(inode->i_sb)->s_uid; 1346 inode->i_uid = UDF_SB(inode->i_sb)->s_uid;
1317 1347
1318 inode->i_gid = le32_to_cpu(fe->gid); 1348 i_gid_write(inode, le32_to_cpu(fe->gid));
1319 if (inode->i_gid == -1 || 1349 if (!gid_valid(inode->i_gid) ||
1320 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) || 1350 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) ||
1321 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET)) 1351 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET))
1322 inode->i_gid = UDF_SB(inode->i_sb)->s_gid; 1352 inode->i_gid = UDF_SB(inode->i_sb)->s_gid;
@@ -1539,12 +1569,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1539 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET)) 1569 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET))
1540 fe->uid = cpu_to_le32(-1); 1570 fe->uid = cpu_to_le32(-1);
1541 else 1571 else
1542 fe->uid = cpu_to_le32(inode->i_uid); 1572 fe->uid = cpu_to_le32(i_uid_read(inode));
1543 1573
1544 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET)) 1574 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET))
1545 fe->gid = cpu_to_le32(-1); 1575 fe->gid = cpu_to_le32(-1);
1546 else 1576 else
1547 fe->gid = cpu_to_le32(inode->i_gid); 1577 fe->gid = cpu_to_le32(i_gid_read(inode));
1548 1578
1549 udfperms = ((inode->i_mode & S_IRWXO)) | 1579 udfperms = ((inode->i_mode & S_IRWXO)) |
1550 ((inode->i_mode & S_IRWXG) << 2) | 1580 ((inode->i_mode & S_IRWXG) << 2) |