Skip to content

Commit

Permalink
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/jack/linux-fs

Pull UDF fixes and quota cleanups from Jan Kara:
 "Several UDF fixes and some minor quota cleanups"

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  udf: Check output buffer length when converting name to CS0
  udf: Prevent buffer overrun with multi-byte characters
  quota: constify qtree_fmt_operations structures
  udf: avoid uninitialized variable use
  udf: Fix lost indirect extent block
  udf: Factor out code for creating indirect extent
  udf: limit the maximum number of indirect extents in a row
  udf: limit the maximum number of TD redirections
  fs: make quota/dquot.c explicitly non-modular
  fs: make quota/netlink.c explicitly non-modular
  • Loading branch information
Linus Torvalds committed Jan 15, 2016
2 parents 875fc4f + bb00c89 commit 1d3671d
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 201 deletions.
2 changes: 1 addition & 1 deletion fs/ocfs2/quota.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct ocfs2_quota_chunk {
extern struct kmem_cache *ocfs2_dquot_cachep;
extern struct kmem_cache *ocfs2_qf_chunk_cachep;

extern struct qtree_fmt_operations ocfs2_global_ops;
extern const struct qtree_fmt_operations ocfs2_global_ops;

struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery(
struct ocfs2_super *osb, int slot_num);
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/quota_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static int ocfs2_global_is_id(void *dp, struct dquot *dquot)
dquot->dq_id);
}

struct qtree_fmt_operations ocfs2_global_ops = {
const struct qtree_fmt_operations ocfs2_global_ops = {
.mem2disk_dqblk = ocfs2_global_mem2diskdqb,
.disk2mem_dqblk = ocfs2_global_disk2memdqb,
.is_id = ocfs2_global_is_id,
Expand Down
2 changes: 1 addition & 1 deletion fs/quota/dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2924,4 +2924,4 @@ static int __init dquot_init(void)

return 0;
}
module_init(dquot_init);
fs_initcall(dquot_init);
5 changes: 1 addition & 4 deletions fs/quota/netlink.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

#include <linux/cred.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/quotaops.h>
#include <linux/sched.h>
Expand Down Expand Up @@ -105,5 +103,4 @@ static int __init quota_init(void)
"VFS: Failed to create quota netlink interface.\n");
return 0;
};

module_init(quota_init);
fs_initcall(quota_init);
4 changes: 2 additions & 2 deletions fs/quota/quota_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot);
static void v2r1_disk2memdqb(struct dquot *dquot, void *dp);
static int v2r1_is_id(void *dp, struct dquot *dquot);

static struct qtree_fmt_operations v2r0_qtree_ops = {
static const struct qtree_fmt_operations v2r0_qtree_ops = {
.mem2disk_dqblk = v2r0_mem2diskdqb,
.disk2mem_dqblk = v2r0_disk2memdqb,
.is_id = v2r0_is_id,
};

static struct qtree_fmt_operations v2r1_qtree_ops = {
static const struct qtree_fmt_operations v2r1_qtree_ops = {
.mem2disk_dqblk = v2r1_mem2diskdqb,
.disk2mem_dqblk = v2r1_disk2memdqb,
.is_id = v2r1_is_id,
Expand Down
98 changes: 5 additions & 93 deletions fs/udf/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,6 @@ static void udf_table_free_blocks(struct super_block *sb,
*/

int adsize;
struct short_ad *sad = NULL;
struct long_ad *lad = NULL;
struct allocExtDesc *aed;

eloc.logicalBlockNum = start;
elen = EXT_RECORDED_ALLOCATED |
Expand All @@ -466,102 +463,17 @@ static void udf_table_free_blocks(struct super_block *sb,
}

if (epos.offset + (2 * adsize) > sb->s_blocksize) {
unsigned char *sptr, *dptr;
int loffset;

brelse(oepos.bh);
oepos = epos;

/* Steal a block from the extent being free'd */
epos.block.logicalBlockNum = eloc.logicalBlockNum;
udf_setup_indirect_aext(table, eloc.logicalBlockNum,
&epos);

eloc.logicalBlockNum++;
elen -= sb->s_blocksize;

epos.bh = udf_tread(sb,
udf_get_lb_pblock(sb, &epos.block, 0));
if (!epos.bh) {
brelse(oepos.bh);
goto error_return;
}
aed = (struct allocExtDesc *)(epos.bh->b_data);
aed->previousAllocExtLocation =
cpu_to_le32(oepos.block.logicalBlockNum);
if (epos.offset + adsize > sb->s_blocksize) {
loffset = epos.offset;
aed->lengthAllocDescs = cpu_to_le32(adsize);
sptr = iinfo->i_ext.i_data + epos.offset
- adsize;
dptr = epos.bh->b_data +
sizeof(struct allocExtDesc);
memcpy(dptr, sptr, adsize);
epos.offset = sizeof(struct allocExtDesc) +
adsize;
} else {
loffset = epos.offset + adsize;
aed->lengthAllocDescs = cpu_to_le32(0);
if (oepos.bh) {
sptr = oepos.bh->b_data + epos.offset;
aed = (struct allocExtDesc *)
oepos.bh->b_data;
le32_add_cpu(&aed->lengthAllocDescs,
adsize);
} else {
sptr = iinfo->i_ext.i_data +
epos.offset;
iinfo->i_lenAlloc += adsize;
mark_inode_dirty(table);
}
epos.offset = sizeof(struct allocExtDesc);
}
if (sbi->s_udfrev >= 0x0200)
udf_new_tag(epos.bh->b_data, TAG_IDENT_AED,
3, 1, epos.block.logicalBlockNum,
sizeof(struct tag));
else
udf_new_tag(epos.bh->b_data, TAG_IDENT_AED,
2, 1, epos.block.logicalBlockNum,
sizeof(struct tag));

switch (iinfo->i_alloc_type) {
case ICBTAG_FLAG_AD_SHORT:
sad = (struct short_ad *)sptr;
sad->extLength = cpu_to_le32(
EXT_NEXT_EXTENT_ALLOCDECS |
sb->s_blocksize);
sad->extPosition =
cpu_to_le32(epos.block.logicalBlockNum);
break;
case ICBTAG_FLAG_AD_LONG:
lad = (struct long_ad *)sptr;
lad->extLength = cpu_to_le32(
EXT_NEXT_EXTENT_ALLOCDECS |
sb->s_blocksize);
lad->extLocation =
cpu_to_lelb(epos.block);
break;
}
if (oepos.bh) {
udf_update_tag(oepos.bh->b_data, loffset);
mark_buffer_dirty(oepos.bh);
} else {
mark_inode_dirty(table);
}
}

/* It's possible that stealing the block emptied the extent */
if (elen) {
udf_write_aext(table, &epos, &eloc, elen, 1);

if (!epos.bh) {
iinfo->i_lenAlloc += adsize;
mark_inode_dirty(table);
} else {
aed = (struct allocExtDesc *)epos.bh->b_data;
le32_add_cpu(&aed->lengthAllocDescs, adsize);
udf_update_tag(epos.bh->b_data, epos.offset);
mark_buffer_dirty(epos.bh);
}
}
if (elen)
__udf_add_aext(table, &epos, &eloc, elen, 1);
}

brelse(epos.bh);
Expand Down
Loading

0 comments on commit 1d3671d

Please sign in to comment.