aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/ialloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/udf/ialloc.c')
-rw-r--r--fs/udf/ialloc.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 8206983f2ebf..636d8f613929 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -28,7 +28,7 @@
28#include "udf_i.h" 28#include "udf_i.h"
29#include "udf_sb.h" 29#include "udf_sb.h"
30 30
31void udf_free_inode(struct inode * inode) 31void udf_free_inode(struct inode *inode)
32{ 32{
33 struct super_block *sb = inode->i_sb; 33 struct super_block *sb = inode->i_sb;
34 struct udf_sb_info *sbi = UDF_SB(sb); 34 struct udf_sb_info *sbi = UDF_SB(sb);
@@ -50,7 +50,7 @@ void udf_free_inode(struct inode * inode)
50 else 50 else
51 UDF_SB_LVIDIU(sb)->numFiles = 51 UDF_SB_LVIDIU(sb)->numFiles =
52 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1); 52 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1);
53 53
54 mark_buffer_dirty(sbi->s_lvidbh); 54 mark_buffer_dirty(sbi->s_lvidbh);
55 } 55 }
56 mutex_unlock(&sbi->s_alloc_mutex); 56 mutex_unlock(&sbi->s_alloc_mutex);
@@ -58,18 +58,17 @@ void udf_free_inode(struct inode * inode)
58 udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1); 58 udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1);
59} 59}
60 60
61struct inode * udf_new_inode (struct inode *dir, int mode, int * err) 61struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
62{ 62{
63 struct super_block *sb = dir->i_sb; 63 struct super_block *sb = dir->i_sb;
64 struct udf_sb_info *sbi = UDF_SB(sb); 64 struct udf_sb_info *sbi = UDF_SB(sb);
65 struct inode * inode; 65 struct inode *inode;
66 int block; 66 int block;
67 uint32_t start = UDF_I_LOCATION(dir).logicalBlockNum; 67 uint32_t start = UDF_I_LOCATION(dir).logicalBlockNum;
68 68
69 inode = new_inode(sb); 69 inode = new_inode(sb);
70 70
71 if (!inode) 71 if (!inode) {
72 {
73 *err = -ENOMEM; 72 *err = -ENOMEM;
74 return NULL; 73 return NULL;
75 } 74 }
@@ -82,16 +81,14 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
82 UDF_I_STRAT4096(inode) = 0; 81 UDF_I_STRAT4096(inode) = 0;
83 82
84 block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum, 83 block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum,
85 start, err); 84 start, err);
86 if (*err) 85 if (*err) {
87 {
88 iput(inode); 86 iput(inode);
89 return NULL; 87 return NULL;
90 } 88 }
91 89
92 mutex_lock(&sbi->s_alloc_mutex); 90 mutex_lock(&sbi->s_alloc_mutex);
93 if (UDF_SB_LVIDBH(sb)) 91 if (UDF_SB_LVIDBH(sb)) {
94 {
95 struct logicalVolHeaderDesc *lvhd; 92 struct logicalVolHeaderDesc *lvhd;
96 uint64_t uniqueID; 93 uint64_t uniqueID;
97 lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse); 94 lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse);
@@ -109,14 +106,13 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
109 } 106 }
110 inode->i_mode = mode; 107 inode->i_mode = mode;
111 inode->i_uid = current->fsuid; 108 inode->i_uid = current->fsuid;
112 if (dir->i_mode & S_ISGID) 109 if (dir->i_mode & S_ISGID) {
113 {
114 inode->i_gid = dir->i_gid; 110 inode->i_gid = dir->i_gid;
115 if (S_ISDIR(mode)) 111 if (S_ISDIR(mode))
116 mode |= S_ISGID; 112 mode |= S_ISGID;
117 } 113 } else {
118 else
119 inode->i_gid = current->fsgid; 114 inode->i_gid = current->fsgid;
115 }
120 116
121 UDF_I_LOCATION(inode).logicalBlockNum = block; 117 UDF_I_LOCATION(inode).logicalBlockNum = block;
122 UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum; 118 UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum;
@@ -125,17 +121,20 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
125 UDF_I_LENEATTR(inode) = 0; 121 UDF_I_LENEATTR(inode) = 0;
126 UDF_I_LENALLOC(inode) = 0; 122 UDF_I_LENALLOC(inode) = 0;
127 UDF_I_USE(inode) = 0; 123 UDF_I_USE(inode) = 0;
128 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) 124 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
129 {
130 UDF_I_EFE(inode) = 1; 125 UDF_I_EFE(inode) = 1;
131 UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); 126 UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE);
132 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL); 127 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL);
133 } 128 } else {
134 else
135 {
136 UDF_I_EFE(inode) = 0; 129 UDF_I_EFE(inode) = 0;
137 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL); 130 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL);
138 } 131 }
132 if (!UDF_I_DATA(inode)) {
133 iput(inode);
134 *err = -ENOMEM;
135 mutex_unlock(&sbi->s_alloc_mutex);
136 return NULL;
137 }
139 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB)) 138 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB))
140 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; 139 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB;
141 else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) 140 else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
@@ -148,8 +147,7 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
148 mark_inode_dirty(inode); 147 mark_inode_dirty(inode);
149 mutex_unlock(&sbi->s_alloc_mutex); 148 mutex_unlock(&sbi->s_alloc_mutex);
150 149
151 if (DQUOT_ALLOC_INODE(inode)) 150 if (DQUOT_ALLOC_INODE(inode)) {
152 {
153 DQUOT_DROP(inode); 151 DQUOT_DROP(inode);
154 inode->i_flags |= S_NOQUOTA; 152 inode->i_flags |= S_NOQUOTA;
155 inode->i_nlink = 0; 153 inode->i_nlink = 0;