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.c69
1 files changed, 36 insertions, 33 deletions
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 10f3188738af..2eb503806bce 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);
@@ -46,10 +46,12 @@ void udf_free_inode(struct inode * inode)
46 if (sbi->s_lvidbh) { 46 if (sbi->s_lvidbh) {
47 if (S_ISDIR(inode->i_mode)) 47 if (S_ISDIR(inode->i_mode))
48 UDF_SB_LVIDIU(sb)->numDirs = 48 UDF_SB_LVIDIU(sb)->numDirs =
49 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1); 49 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)
50 - 1);
50 else 51 else
51 UDF_SB_LVIDIU(sb)->numFiles = 52 UDF_SB_LVIDIU(sb)->numFiles =
52 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1); 53 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles)
54 - 1);
53 55
54 mark_buffer_dirty(sbi->s_lvidbh); 56 mark_buffer_dirty(sbi->s_lvidbh);
55 } 57 }
@@ -58,18 +60,17 @@ void udf_free_inode(struct inode * inode)
58 udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1); 60 udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1);
59} 61}
60 62
61struct inode * udf_new_inode (struct inode *dir, int mode, int * err) 63struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
62{ 64{
63 struct super_block *sb = dir->i_sb; 65 struct super_block *sb = dir->i_sb;
64 struct udf_sb_info *sbi = UDF_SB(sb); 66 struct udf_sb_info *sbi = UDF_SB(sb);
65 struct inode * inode; 67 struct inode *inode;
66 int block; 68 int block;
67 uint32_t start = UDF_I_LOCATION(dir).logicalBlockNum; 69 uint32_t start = UDF_I_LOCATION(dir).logicalBlockNum;
68 70
69 inode = new_inode(sb); 71 inode = new_inode(sb);
70 72
71 if (!inode) 73 if (!inode) {
72 {
73 *err = -ENOMEM; 74 *err = -ENOMEM;
74 return NULL; 75 return NULL;
75 } 76 }
@@ -81,26 +82,30 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
81 UDF_I_NEXT_ALLOC_GOAL(inode) = 0; 82 UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
82 UDF_I_STRAT4096(inode) = 0; 83 UDF_I_STRAT4096(inode) = 0;
83 84
84 block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum, 85 block =
85 start, err); 86 udf_new_block(dir->i_sb, NULL,
86 if (*err) 87 UDF_I_LOCATION(dir).partitionReferenceNum, start,
87 { 88 err);
89 if (*err) {
88 iput(inode); 90 iput(inode);
89 return NULL; 91 return NULL;
90 } 92 }
91 93
92 mutex_lock(&sbi->s_alloc_mutex); 94 mutex_lock(&sbi->s_alloc_mutex);
93 if (UDF_SB_LVIDBH(sb)) 95 if (UDF_SB_LVIDBH(sb)) {
94 {
95 struct logicalVolHeaderDesc *lvhd; 96 struct logicalVolHeaderDesc *lvhd;
96 uint64_t uniqueID; 97 uint64_t uniqueID;
97 lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse); 98 lvhd =
99 (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->
100 logicalVolContentsUse);
98 if (S_ISDIR(mode)) 101 if (S_ISDIR(mode))
99 UDF_SB_LVIDIU(sb)->numDirs = 102 UDF_SB_LVIDIU(sb)->numDirs =
100 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1); 103 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)
104 + 1);
101 else 105 else
102 UDF_SB_LVIDIU(sb)->numFiles = 106 UDF_SB_LVIDIU(sb)->numFiles =
103 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1); 107 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles)
108 + 1);
104 UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID); 109 UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID);
105 if (!(++uniqueID & 0x00000000FFFFFFFFUL)) 110 if (!(++uniqueID & 0x00000000FFFFFFFFUL))
106 uniqueID += 16; 111 uniqueID += 16;
@@ -109,35 +114,34 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
109 } 114 }
110 inode->i_mode = mode; 115 inode->i_mode = mode;
111 inode->i_uid = current->fsuid; 116 inode->i_uid = current->fsuid;
112 if (dir->i_mode & S_ISGID) 117 if (dir->i_mode & S_ISGID) {
113 {
114 inode->i_gid = dir->i_gid; 118 inode->i_gid = dir->i_gid;
115 if (S_ISDIR(mode)) 119 if (S_ISDIR(mode))
116 mode |= S_ISGID; 120 mode |= S_ISGID;
117 } 121 } else
118 else
119 inode->i_gid = current->fsgid; 122 inode->i_gid = current->fsgid;
120 123
121 UDF_I_LOCATION(inode).logicalBlockNum = block; 124 UDF_I_LOCATION(inode).logicalBlockNum = block;
122 UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum; 125 UDF_I_LOCATION(inode).partitionReferenceNum =
126 UDF_I_LOCATION(dir).partitionReferenceNum;
123 inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0); 127 inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0);
124 inode->i_blocks = 0; 128 inode->i_blocks = 0;
125 UDF_I_LENEATTR(inode) = 0; 129 UDF_I_LENEATTR(inode) = 0;
126 UDF_I_LENALLOC(inode) = 0; 130 UDF_I_LENALLOC(inode) = 0;
127 UDF_I_USE(inode) = 0; 131 UDF_I_USE(inode) = 0;
128 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) 132 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
129 {
130 UDF_I_EFE(inode) = 1; 133 UDF_I_EFE(inode) = 1;
131 UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); 134 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); 135 UDF_I_DATA(inode) =
133 } 136 kzalloc(inode->i_sb->s_blocksize -
134 else 137 sizeof(struct extendedFileEntry), GFP_KERNEL);
135 { 138 } else {
136 UDF_I_EFE(inode) = 0; 139 UDF_I_EFE(inode) = 0;
137 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL); 140 UDF_I_DATA(inode) =
141 kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry),
142 GFP_KERNEL);
138 } 143 }
139 if (!UDF_I_DATA(inode)) 144 if (!UDF_I_DATA(inode)) {
140 {
141 iput(inode); 145 iput(inode);
142 *err = -ENOMEM; 146 *err = -ENOMEM;
143 mutex_unlock(&sbi->s_alloc_mutex); 147 mutex_unlock(&sbi->s_alloc_mutex);
@@ -150,13 +154,12 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
150 else 154 else
151 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG; 155 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG;
152 inode->i_mtime = inode->i_atime = inode->i_ctime = 156 inode->i_mtime = inode->i_atime = inode->i_ctime =
153 UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb); 157 UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb);
154 insert_inode_hash(inode); 158 insert_inode_hash(inode);
155 mark_inode_dirty(inode); 159 mark_inode_dirty(inode);
156 mutex_unlock(&sbi->s_alloc_mutex); 160 mutex_unlock(&sbi->s_alloc_mutex);
157 161
158 if (DQUOT_ALLOC_INODE(inode)) 162 if (DQUOT_ALLOC_INODE(inode)) {
159 {
160 DQUOT_DROP(inode); 163 DQUOT_DROP(inode);
161 inode->i_flags |= S_NOQUOTA; 164 inode->i_flags |= S_NOQUOTA;
162 inode->i_nlink = 0; 165 inode->i_nlink = 0;