Skip to content

Commit

Permalink
udf: Perform preallocation only for regular files
Browse files Browse the repository at this point in the history
So far we preallocated blocks also for directories but that brings a
problem, when to get rid of preallocated blocks we don't need. So far
we removed them in udf_clear_inode() which has a disadvantage that
1) blocks are unavailable long after writing to a directory finished
   and thus one can get out of space unnecessarily early
2) releasing blocks from udf_clear_inode is problematic because VFS
   does not expect us to redirty inode there and it also slows down
   memory reclaim.

So preallocate blocks only for regular files where we can drop preallocation
in udf_release_file.

Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
jankara committed Sep 14, 2009
1 parent 7c6e3d1 commit 81056dd
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions fs/udf/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,16 @@ void udf_delete_inode(struct inode *inode)
}

/*
* If we are going to release inode from memory, we discard preallocation and
* truncate last inode extent to proper length. We could use drop_inode() but
* it's called under inode_lock and thus we cannot mark inode dirty there. We
* use clear_inode() but we have to make sure to write inode as it's not written
* automatically.
* If we are going to release inode from memory, we truncate last inode extent
* to proper length. We could use drop_inode() but it's called under inode_lock
* and thus we cannot mark inode dirty there. We use clear_inode() but we have
* to make sure to write inode as it's not written automatically.
*/
void udf_clear_inode(struct inode *inode)
{
struct udf_inode_info *iinfo;
if (!(inode->i_sb->s_flags & MS_RDONLY)) {
lock_kernel();
/* Discard preallocation for directories, symlinks, etc. */
udf_discard_prealloc(inode);
udf_truncate_tail_extent(inode);
unlock_kernel();
write_inode_now(inode, 0);
Expand Down Expand Up @@ -664,8 +661,12 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum);

#ifdef UDF_PREALLOCATE
/* preallocate blocks */
udf_prealloc_extents(inode, c, lastblock, laarr, &endnum);
/* We preallocate blocks only for regular files. It also makes sense
* for directories but there's a problem when to drop the
* preallocation. We might use some delayed work for that but I feel
* it's overengineering for a filesystem like UDF. */
if (S_ISREG(inode->i_mode))
udf_prealloc_extents(inode, c, lastblock, laarr, &endnum);
#endif

/* merge any continuous blocks in laarr */
Expand Down

0 comments on commit 81056dd

Please sign in to comment.