aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ufs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ufs')
-rw-r--r--fs/ufs/balloc.c25
-rw-r--r--fs/ufs/dir.c2
-rw-r--r--fs/ufs/inode.c41
-rw-r--r--fs/ufs/super.c12
-rw-r--r--fs/ufs/util.h2
5 files changed, 38 insertions, 44 deletions
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index b82381475779..2e0021e8f366 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -275,6 +275,25 @@ static void ufs_change_blocknr(struct inode *inode, unsigned int baseblk,
275 UFSD("EXIT\n"); 275 UFSD("EXIT\n");
276} 276}
277 277
278static void ufs_clear_frags(struct inode *inode, sector_t beg, unsigned int n,
279 int sync)
280{
281 struct buffer_head *bh;
282 sector_t end = beg + n;
283
284 for (; beg < end; ++beg) {
285 bh = sb_getblk(inode->i_sb, beg);
286 lock_buffer(bh);
287 memset(bh->b_data, 0, inode->i_sb->s_blocksize);
288 set_buffer_uptodate(bh);
289 mark_buffer_dirty(bh);
290 unlock_buffer(bh);
291 if (IS_SYNC(inode) || sync)
292 sync_dirty_buffer(bh);
293 brelse(bh);
294 }
295}
296
278unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment, 297unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
279 unsigned goal, unsigned count, int * err, struct page *locked_page) 298 unsigned goal, unsigned count, int * err, struct page *locked_page)
280{ 299{
@@ -350,6 +369,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
350 *p = cpu_to_fs32(sb, result); 369 *p = cpu_to_fs32(sb, result);
351 *err = 0; 370 *err = 0;
352 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); 371 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
372 ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
373 locked_page != NULL);
353 } 374 }
354 unlock_super(sb); 375 unlock_super(sb);
355 UFSD("EXIT, result %u\n", result); 376 UFSD("EXIT, result %u\n", result);
@@ -363,6 +384,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
363 if (result) { 384 if (result) {
364 *err = 0; 385 *err = 0;
365 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); 386 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
387 ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
388 locked_page != NULL);
366 unlock_super(sb); 389 unlock_super(sb);
367 UFSD("EXIT, result %u\n", result); 390 UFSD("EXIT, result %u\n", result);
368 return result; 391 return result;
@@ -398,6 +421,8 @@ unsigned ufs_new_fragments(struct inode * inode, __fs32 * p, unsigned fragment,
398 *p = cpu_to_fs32(sb, result); 421 *p = cpu_to_fs32(sb, result);
399 *err = 0; 422 *err = 0;
400 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); 423 UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count);
424 ufs_clear_frags(inode, result + oldcount, newcount - oldcount,
425 locked_page != NULL);
401 unlock_super(sb); 426 unlock_super(sb);
402 if (newcount < request) 427 if (newcount < request)
403 ufs_free_fragments (inode, result + newcount, request - newcount); 428 ufs_free_fragments (inode, result + newcount, request - newcount);
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index 7f0a0aa63584..433b6f68403a 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -426,7 +426,7 @@ static int
426ufs_readdir(struct file *filp, void *dirent, filldir_t filldir) 426ufs_readdir(struct file *filp, void *dirent, filldir_t filldir)
427{ 427{
428 loff_t pos = filp->f_pos; 428 loff_t pos = filp->f_pos;
429 struct inode *inode = filp->f_dentry->d_inode; 429 struct inode *inode = filp->f_path.dentry->d_inode;
430 struct super_block *sb = inode->i_sb; 430 struct super_block *sb = inode->i_sb;
431 unsigned int offset = pos & ~PAGE_CACHE_MASK; 431 unsigned int offset = pos & ~PAGE_CACHE_MASK;
432 unsigned long n = pos >> PAGE_CACHE_SHIFT; 432 unsigned long n = pos >> PAGE_CACHE_SHIFT;
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index ee1eaa6f4ec2..2fbab0aab688 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -156,36 +156,6 @@ out:
156 return ret; 156 return ret;
157} 157}
158 158
159static void ufs_clear_frag(struct inode *inode, struct buffer_head *bh)
160{
161 lock_buffer(bh);
162 memset(bh->b_data, 0, inode->i_sb->s_blocksize);
163 set_buffer_uptodate(bh);
164 mark_buffer_dirty(bh);
165 unlock_buffer(bh);
166 if (IS_SYNC(inode))
167 sync_dirty_buffer(bh);
168}
169
170static struct buffer_head *
171ufs_clear_frags(struct inode *inode, sector_t beg,
172 unsigned int n, sector_t want)
173{
174 struct buffer_head *res = NULL, *bh;
175 sector_t end = beg + n;
176
177 for (; beg < end; ++beg) {
178 bh = sb_getblk(inode->i_sb, beg);
179 ufs_clear_frag(inode, bh);
180 if (want != beg)
181 brelse(bh);
182 else
183 res = bh;
184 }
185 BUG_ON(!res);
186 return res;
187}
188
189/** 159/**
190 * ufs_inode_getfrag() - allocate new fragment(s) 160 * ufs_inode_getfrag() - allocate new fragment(s)
191 * @inode - pointer to inode 161 * @inode - pointer to inode
@@ -302,7 +272,7 @@ repeat:
302 } 272 }
303 273
304 if (!phys) { 274 if (!phys) {
305 result = ufs_clear_frags(inode, tmp, required, tmp + blockoff); 275 result = sb_getblk(sb, tmp + blockoff);
306 } else { 276 } else {
307 *phys = tmp + blockoff; 277 *phys = tmp + blockoff;
308 result = NULL; 278 result = NULL;
@@ -403,8 +373,7 @@ repeat:
403 373
404 374
405 if (!phys) { 375 if (!phys) {
406 result = ufs_clear_frags(inode, tmp, uspi->s_fpb, 376 result = sb_getblk(sb, tmp + blockoff);
407 tmp + blockoff);
408 } else { 377 } else {
409 *phys = tmp + blockoff; 378 *phys = tmp + blockoff;
410 *new = 1; 379 *new = 1;
@@ -471,13 +440,13 @@ int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head
471#define GET_INODE_DATABLOCK(x) \ 440#define GET_INODE_DATABLOCK(x) \
472 ufs_inode_getfrag(inode, x, fragment, 1, &err, &phys, &new, bh_result->b_page) 441 ufs_inode_getfrag(inode, x, fragment, 1, &err, &phys, &new, bh_result->b_page)
473#define GET_INODE_PTR(x) \ 442#define GET_INODE_PTR(x) \
474 ufs_inode_getfrag(inode, x, fragment, uspi->s_fpb, &err, NULL, NULL, bh_result->b_page) 443 ufs_inode_getfrag(inode, x, fragment, uspi->s_fpb, &err, NULL, NULL, NULL)
475#define GET_INDIRECT_DATABLOCK(x) \ 444#define GET_INDIRECT_DATABLOCK(x) \
476 ufs_inode_getblock(inode, bh, x, fragment, \ 445 ufs_inode_getblock(inode, bh, x, fragment, \
477 &err, &phys, &new, bh_result->b_page); 446 &err, &phys, &new, bh_result->b_page)
478#define GET_INDIRECT_PTR(x) \ 447#define GET_INDIRECT_PTR(x) \
479 ufs_inode_getblock(inode, bh, x, fragment, \ 448 ufs_inode_getblock(inode, bh, x, fragment, \
480 &err, NULL, NULL, bh_result->b_page); 449 &err, NULL, NULL, NULL)
481 450
482 if (ptr < UFS_NDIR_FRAGMENT) { 451 if (ptr < UFS_NDIR_FRAGMENT) {
483 bh = GET_INODE_DATABLOCK(ptr); 452 bh = GET_INODE_DATABLOCK(ptr);
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index ec79e3091d1b..8a8e9382ec09 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -224,7 +224,7 @@ void ufs_error (struct super_block * sb, const char * function,
224 sb->s_flags |= MS_RDONLY; 224 sb->s_flags |= MS_RDONLY;
225 } 225 }
226 va_start (args, fmt); 226 va_start (args, fmt);
227 vsprintf (error_buf, fmt, args); 227 vsnprintf (error_buf, sizeof(error_buf), fmt, args);
228 va_end (args); 228 va_end (args);
229 switch (UFS_SB(sb)->s_mount_opt & UFS_MOUNT_ONERROR) { 229 switch (UFS_SB(sb)->s_mount_opt & UFS_MOUNT_ONERROR) {
230 case UFS_MOUNT_ONERROR_PANIC: 230 case UFS_MOUNT_ONERROR_PANIC:
@@ -255,7 +255,7 @@ void ufs_panic (struct super_block * sb, const char * function,
255 sb->s_dirt = 1; 255 sb->s_dirt = 1;
256 } 256 }
257 va_start (args, fmt); 257 va_start (args, fmt);
258 vsprintf (error_buf, fmt, args); 258 vsnprintf (error_buf, sizeof(error_buf), fmt, args);
259 va_end (args); 259 va_end (args);
260 sb->s_flags |= MS_RDONLY; 260 sb->s_flags |= MS_RDONLY;
261 printk (KERN_CRIT "UFS-fs panic (device %s): %s: %s\n", 261 printk (KERN_CRIT "UFS-fs panic (device %s): %s: %s\n",
@@ -268,7 +268,7 @@ void ufs_warning (struct super_block * sb, const char * function,
268 va_list args; 268 va_list args;
269 269
270 va_start (args, fmt); 270 va_start (args, fmt);
271 vsprintf (error_buf, fmt, args); 271 vsnprintf (error_buf, sizeof(error_buf), fmt, args);
272 va_end (args); 272 va_end (args);
273 printk (KERN_WARNING "UFS-fs warning (device %s): %s: %s\n", 273 printk (KERN_WARNING "UFS-fs warning (device %s): %s: %s\n",
274 sb->s_id, function, error_buf); 274 sb->s_id, function, error_buf);
@@ -1204,12 +1204,12 @@ static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf)
1204 return 0; 1204 return 0;
1205} 1205}
1206 1206
1207static kmem_cache_t * ufs_inode_cachep; 1207static struct kmem_cache * ufs_inode_cachep;
1208 1208
1209static struct inode *ufs_alloc_inode(struct super_block *sb) 1209static struct inode *ufs_alloc_inode(struct super_block *sb)
1210{ 1210{
1211 struct ufs_inode_info *ei; 1211 struct ufs_inode_info *ei;
1212 ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, SLAB_KERNEL); 1212 ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, GFP_KERNEL);
1213 if (!ei) 1213 if (!ei)
1214 return NULL; 1214 return NULL;
1215 ei->vfs_inode.i_version = 1; 1215 ei->vfs_inode.i_version = 1;
@@ -1221,7 +1221,7 @@ static void ufs_destroy_inode(struct inode *inode)
1221 kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); 1221 kmem_cache_free(ufs_inode_cachep, UFS_I(inode));
1222} 1222}
1223 1223
1224static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 1224static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
1225{ 1225{
1226 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo; 1226 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo;
1227 1227
diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index 28fce6c239b5..7dd12bb1d62b 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -299,7 +299,7 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi,
299 299
300#define ubh_get_addr16(ubh,begin) \ 300#define ubh_get_addr16(ubh,begin) \
301 (((__fs16*)((ubh)->bh[(begin) >> (uspi->s_fshift-1)]->b_data)) + \ 301 (((__fs16*)((ubh)->bh[(begin) >> (uspi->s_fshift-1)]->b_data)) + \
302 ((begin) & (uspi->fsize>>1) - 1))) 302 ((begin) & ((uspi->fsize>>1) - 1)))
303 303
304#define ubh_get_addr32(ubh,begin) \ 304#define ubh_get_addr32(ubh,begin) \
305 (((__fs32*)((ubh)->bh[(begin) >> (uspi->s_fshift-2)]->b_data)) + \ 305 (((__fs32*)((ubh)->bh[(begin) >> (uspi->s_fshift-2)]->b_data)) + \