diff options
author | Christoph Hellwig <hch@lst.de> | 2008-02-08 07:20:26 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 12:22:34 -0500 |
commit | 8b88b0998e35d239e74446cc30f354bdab86df89 (patch) | |
tree | c13773b744cf12b1e30ec9336a4acaf21e46c6d9 /virt | |
parent | efae09f3e99fcc1bdead7bc23a508b3bade3f82f (diff) |
libfs: allow error return from simple attributes
Sometimes simple attributes might need to return an error, e.g. for
acquiring a mutex interruptibly. In fact we have that situation in
spufs already which is the original user of the simple attributes. This
patch merged the temporarily forked attributes in spufs back into the
main ones and allows to return errors.
[akpm@linux-foundation.org: build fix]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: <stefano.brivio@polimi.it>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg KH <greg@kroah.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 3c4fe26096fc..32fbf8006969 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -1186,38 +1186,38 @@ static struct notifier_block kvm_cpu_notifier = { | |||
1186 | .priority = 20, /* must be > scheduler priority */ | 1186 | .priority = 20, /* must be > scheduler priority */ |
1187 | }; | 1187 | }; |
1188 | 1188 | ||
1189 | static u64 vm_stat_get(void *_offset) | 1189 | static int vm_stat_get(void *_offset, u64 *val) |
1190 | { | 1190 | { |
1191 | unsigned offset = (long)_offset; | 1191 | unsigned offset = (long)_offset; |
1192 | u64 total = 0; | ||
1193 | struct kvm *kvm; | 1192 | struct kvm *kvm; |
1194 | 1193 | ||
1194 | *val = 0; | ||
1195 | spin_lock(&kvm_lock); | 1195 | spin_lock(&kvm_lock); |
1196 | list_for_each_entry(kvm, &vm_list, vm_list) | 1196 | list_for_each_entry(kvm, &vm_list, vm_list) |
1197 | total += *(u32 *)((void *)kvm + offset); | 1197 | *val += *(u32 *)((void *)kvm + offset); |
1198 | spin_unlock(&kvm_lock); | 1198 | spin_unlock(&kvm_lock); |
1199 | return total; | 1199 | return 0; |
1200 | } | 1200 | } |
1201 | 1201 | ||
1202 | DEFINE_SIMPLE_ATTRIBUTE(vm_stat_fops, vm_stat_get, NULL, "%llu\n"); | 1202 | DEFINE_SIMPLE_ATTRIBUTE(vm_stat_fops, vm_stat_get, NULL, "%llu\n"); |
1203 | 1203 | ||
1204 | static u64 vcpu_stat_get(void *_offset) | 1204 | static int vcpu_stat_get(void *_offset, u64 *val) |
1205 | { | 1205 | { |
1206 | unsigned offset = (long)_offset; | 1206 | unsigned offset = (long)_offset; |
1207 | u64 total = 0; | ||
1208 | struct kvm *kvm; | 1207 | struct kvm *kvm; |
1209 | struct kvm_vcpu *vcpu; | 1208 | struct kvm_vcpu *vcpu; |
1210 | int i; | 1209 | int i; |
1211 | 1210 | ||
1211 | *val = 0; | ||
1212 | spin_lock(&kvm_lock); | 1212 | spin_lock(&kvm_lock); |
1213 | list_for_each_entry(kvm, &vm_list, vm_list) | 1213 | list_for_each_entry(kvm, &vm_list, vm_list) |
1214 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { | 1214 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { |
1215 | vcpu = kvm->vcpus[i]; | 1215 | vcpu = kvm->vcpus[i]; |
1216 | if (vcpu) | 1216 | if (vcpu) |
1217 | total += *(u32 *)((void *)vcpu + offset); | 1217 | *val += *(u32 *)((void *)vcpu + offset); |
1218 | } | 1218 | } |
1219 | spin_unlock(&kvm_lock); | 1219 | spin_unlock(&kvm_lock); |
1220 | return total; | 1220 | return 0; |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | DEFINE_SIMPLE_ATTRIBUTE(vcpu_stat_fops, vcpu_stat_get, NULL, "%llu\n"); | 1223 | DEFINE_SIMPLE_ATTRIBUTE(vcpu_stat_fops, vcpu_stat_get, NULL, "%llu\n"); |