lkml.org 
[lkml]   [2005]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] 2.6.14 patch for supporting madvise(MADV_REMOVE)
Badari Pulavarty <pbadari@us.ibm.com> wrote:
>
> +int vmtruncate_range(struct inode * inode, loff_t offset, loff_t end)
> +{
> + struct address_space *mapping = inode->i_mapping;
> +
> + /*
> + * If the underlying filesystem is not going to provide
> + * a way to truncate a range of blocks (punch a hole) -
> + * we should return failure right now.
> + */
> + if (!inode->i_op || !inode->i_op->truncate_range)
> + return -ENOSYS;
> +
> + /* XXX - Do we need both i_sem and i_allocsem all the way ? */
> + down(&inode->i_sem);
> + down_write(&inode->i_alloc_sem);
> + unmap_mapping_range(mapping, offset, (end - offset), 1);
> + truncate_inode_pages_range(mapping, offset, end);
> + inode->i_op->truncate_range(inode, offset, end);
> + up_write(&inode->i_alloc_sem);
> + up(&inode->i_sem);
> +
> + return 0;
> +}

Yes, we need to take i_alloc_sem for writing. To prevent concurrent
direct-io reads from coming in and instantiated by unwritten blocks.

tmpfs doesn't implements direct-io though.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-11-12 01:37    [from the cache]
©2003-2011 Jasper Spaans