I'm trying to solve
DSolve[f[x]*(x^2*g''[x] - 2*g[x] + 2) + x*(x*g'[x] - 2*g[x])*f'[x] == 0, g[x], x]
for $g(x)$, however Mathematica cannot find a solution. It can find a solution for $f(x)$ but it is rather complicated. I tried a little bit to solve it by hand and after some manipulations i found that
$$g(x) = x^2 \left(a+\int \frac{b-\int 2 f(x) \, dx}{x^4 f(x)} \, dx\right)$$
where $a,b$ are constants, which satisfies the differential equation. I would like to ask why Mathematica cannot integrate this? Is there somehting wrong that i'm doing? Can i force somehow Mathematica to solve this?