Commit 041d6d0b authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-udf-2.6

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-udf-2.6:
  udf: Fix possible corruption when close races with write
  udf: Perform preallocation only for regular files
  udf: Remove wrong assignment in udf_symlink
  udf: Remove dead code
parents af8cb8aa cbc8cc33
...@@ -18,59 +18,6 @@ ...@@ -18,59 +18,6 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#if 0
static uint8_t *udf_filead_read(struct inode *dir, uint8_t *tmpad,
uint8_t ad_size, struct kernel_lb_addr fe_loc,
int *pos, int *offset, struct buffer_head **bh,
int *error)
{
int loffset = *offset;
int block;
uint8_t *ad;
int remainder;
*error = 0;
ad = (uint8_t *)(*bh)->b_data + *offset;
*offset += ad_size;
if (!ad) {
brelse(*bh);
*error = 1;
return NULL;
}
if (*offset == dir->i_sb->s_blocksize) {
brelse(*bh);
block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
if (!block)
return NULL;
*bh = udf_tread(dir->i_sb, block);
if (!*bh)
return NULL;
} else if (*offset > dir->i_sb->s_blocksize) {
ad = tmpad;
remainder = dir->i_sb->s_blocksize - loffset;
memcpy((uint8_t *)ad, (*bh)->b_data + loffset, remainder);
brelse(*bh);
block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
if (!block)
return NULL;
(*bh) = udf_tread(dir->i_sb, block);
if (!*bh)
return NULL;
memcpy((uint8_t *)ad + remainder, (*bh)->b_data,
ad_size - remainder);
*offset = ad_size - remainder;
}
return ad;
}
#endif
struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos,
struct udf_fileident_bh *fibh, struct udf_fileident_bh *fibh,
struct fileIdentDesc *cfi, struct fileIdentDesc *cfi,
...@@ -248,39 +195,6 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset) ...@@ -248,39 +195,6 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
return fi; return fi;
} }
#if 0
static struct extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
{
struct extent_ad *ext;
struct fileEntry *fe;
uint8_t *ptr;
if ((!buffer) || (!offset)) {
printk(KERN_ERR "udf: udf_get_fileextent() invalidparms\n");
return NULL;
}
fe = (struct fileEntry *)buffer;
if (fe->descTag.tagIdent != cpu_to_le16(TAG_IDENT_FE)) {
udf_debug("0x%x != TAG_IDENT_FE\n",
le16_to_cpu(fe->descTag.tagIdent));
return NULL;
}
ptr = (uint8_t *)(fe->extendedAttr) +
le32_to_cpu(fe->lengthExtendedAttr);
if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs)))
ptr += *offset;
ext = (struct extent_ad *)ptr;
*offset = *offset + sizeof(struct extent_ad);
return ext;
}
#endif
struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset, struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset,
int inc) int inc)
{ {
......
...@@ -193,9 +193,11 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -193,9 +193,11 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
static int udf_release_file(struct inode *inode, struct file *filp) static int udf_release_file(struct inode *inode, struct file *filp)
{ {
if (filp->f_mode & FMODE_WRITE) { if (filp->f_mode & FMODE_WRITE) {
mutex_lock(&inode->i_mutex);
lock_kernel(); lock_kernel();
udf_discard_prealloc(inode); udf_discard_prealloc(inode);
unlock_kernel(); unlock_kernel();
mutex_unlock(&inode->i_mutex);
} }
return 0; return 0;
} }
......
...@@ -90,19 +90,16 @@ void udf_delete_inode(struct inode *inode) ...@@ -90,19 +90,16 @@ void udf_delete_inode(struct inode *inode)
} }
/* /*
* If we are going to release inode from memory, we discard preallocation and * If we are going to release inode from memory, we truncate last inode extent
* truncate last inode extent to proper length. We could use drop_inode() but * to proper length. We could use drop_inode() but it's called under inode_lock
* it's called under inode_lock and thus we cannot mark inode dirty there. We * and thus we cannot mark inode dirty there. We use clear_inode() but we have
* use clear_inode() but we have to make sure to write inode as it's not written * to make sure to write inode as it's not written automatically.
* automatically.
*/ */
void udf_clear_inode(struct inode *inode) void udf_clear_inode(struct inode *inode)
{ {
struct udf_inode_info *iinfo; struct udf_inode_info *iinfo;
if (!(inode->i_sb->s_flags & MS_RDONLY)) { if (!(inode->i_sb->s_flags & MS_RDONLY)) {
lock_kernel(); lock_kernel();
/* Discard preallocation for directories, symlinks, etc. */
udf_discard_prealloc(inode);
udf_truncate_tail_extent(inode); udf_truncate_tail_extent(inode);
unlock_kernel(); unlock_kernel();
write_inode_now(inode, 0); write_inode_now(inode, 0);
...@@ -664,8 +661,12 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, ...@@ -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); udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum);
#ifdef UDF_PREALLOCATE #ifdef UDF_PREALLOCATE
/* preallocate blocks */ /* We preallocate blocks only for regular files. It also makes sense
udf_prealloc_extents(inode, c, lastblock, laarr, &endnum); * 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 #endif
/* merge any continuous blocks in laarr */ /* merge any continuous blocks in laarr */
......
...@@ -36,14 +36,10 @@ unsigned int udf_get_last_session(struct super_block *sb) ...@@ -36,14 +36,10 @@ unsigned int udf_get_last_session(struct super_block *sb)
ms_info.addr_format = CDROM_LBA; ms_info.addr_format = CDROM_LBA;
i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long)&ms_info); i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long)&ms_info);
#define WE_OBEY_THE_WRITTEN_STANDARDS 1
if (i == 0) { if (i == 0) {
udf_debug("XA disk: %s, vol_desc_start=%d\n", udf_debug("XA disk: %s, vol_desc_start=%d\n",
(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba); (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
#if WE_OBEY_THE_WRITTEN_STANDARDS
if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */ if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
#endif
vol_desc_start = ms_info.addr.lba; vol_desc_start = ms_info.addr.lba;
} else { } else {
udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i); udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i);
......
...@@ -943,7 +943,6 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, ...@@ -943,7 +943,6 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
pc->componentType = 1; pc->componentType = 1;
pc->lengthComponentIdent = 0; pc->lengthComponentIdent = 0;
pc->componentFileVersionNum = 0; pc->componentFileVersionNum = 0;
pc += sizeof(struct pathComponent);
elen += sizeof(struct pathComponent); elen += sizeof(struct pathComponent);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment